﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.Entity.Core.Objects;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Remoting;
using System.Text;
using System.Text.RegularExpressions;
using FL.Entity.DB;
using FL.Lite.sqlserver;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FL.Bussiness;
using FL.DBModule.Sys;
using FL.DBModule;
//=============================================================
// Copyright (C) 2015 福流网络
// 作 者：詹勇
// 日 期：2015-07-16
// 描 述: 逻辑审核 测试类
// 版 本：1.00
// 修改历史纪录
// 版 本  修改时间      修改人            修改内容

//=============================================================
namespace FL.Test
{
    [TestClass]
    public class BuseinessTest
    {
        Fuliu_TestEntities fuliuEntities = new Fuliu_TestEntities();


        [TestMethod]
        public void TestMethod2()
        {
            DataImport.DataImportBase import = new DataImport.DataImportBase();
            DataTable dt = import.GetExeclTable("e:\\test.xls");
            import.Import(dt, "t_test_name");
        }

        [TestMethod]
        public void TestMethod1()
        {
            BaseBussnies bll = new BaseBussnies();
            TableInfoStruc t = new TableInfoStruc();
            IList<TableInfoStruc> list = bll.GetEntitys<TableInfoStruc>("TableName='t_sys_function'");
            StringBuilder html = new StringBuilder("");
            html.Append(" <table style=\"width: 100%;\">");
            if (list != null)
            {
                foreach (TableInfoStruc table in list)
                {
                    string template = @" <tr>
                                <td class=""theader"">{0}</td>
                                <td>
                                    <input id=""{1}"" name=""{1}"" allowinput=""true"" shownullitem=""false"" class=""mini_{2}"" style=""width: 100%;""/>
                                </td>
                            </tr>";
                    html.AppendLine(string.Format(template, table.ColDesc, table.ColName, "textbox"));
                }

            }
            html.Append("</table>");
            FL.Common.FileHelper.GenerateFile("E://Temp", html.ToString(), "aspx");
            //lib.add_time = System.DateTime.Now;
            //lib.add_user = System.Guid.Empty;
            //lib.name = "FL.Bussiness,FL.Bussiness.BaseBussiness";
            //lib.type = "e";
            // bll.entity = lib;
            bll.Insert();
        }

        [TestMethod]
        public void TestRuleEngine()
        {
            // Bussiness bll = new Bussiness();
            //int id;
            //id = 869956;
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.pack_no = "";
            string role = @"m = '';  
            if(entity.pack_no=='')  
            {    
                m= m   + '包装方式不能为空\r\n';   
            }
            return m;";


            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);

        }

        /// <summary>
        /// 测试规则引擎 IsNullOrEmpty
        /// </summary>
        [TestMethod]
        public void TestRuleEngineString()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.pack_no = "";
            string role = @"m = '';  
            if(string.IsNullOrEmpty(entity.pack_no))  
            {    
                m= m   + '包装方式不能为空\r\n';   
            }
            return m;";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
        }

        /// <summary>
        /// 测试规则引擎 字符串长度
        /// </summary>
        [TestMethod]
        public void TestRuleEngineStringLentgh()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.pack_no = "123142243";
            string role = @"m = '';  
             m=entity.pack_no.ToString().Length;
            return m;";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
        }

        /// <summary>
        /// 测试规则引擎  list
        /// </summary>
        [TestMethod]
        public void TestRuleEngineList()
        {
            List<int> l = new List<int>();
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.pack_no = "123142243";
            string role = @" 
            a = new ListString();
            a.Add('a');
            a.Add('b');
            a.Add('c');
            a.Sort();
            intlist.Sort();
            IEnumerable<|int|>.Where<|int|>(function(x){ return x==1;});
            result = 'asdf';
           return result;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
        }

        #region 逻辑审核 测试

        string functionstr = @"RemoveNull =function(data)
            { 
               if(data == null) 
                 return '';
               else
                 return data.ToString();  
            };

       DigitalRemoveNull =function(data)
            { 
               if(data == null | data == '' )
                 return '0';
               else
                 return data;  
            };
  
             ";

        /// <summary>
        /// 逻辑审核1  流水号长度不符或者流水号第2位与大鹏不一致！
        /// </summary>
        [TestMethod]
        public void TestLogic1()
        {



            List<int> l = new List<int>();
            //FL.Entity.DB.t_mains mains = new t_mains();
            //mains.cabin_no = "12345678910";
            //mains.port_no = "5316";
            //mains.transmode_no = "2";
            //mains.declare_id = 1;

            var mains = fuliuEntities.t_mains.Where(t => t.id == 883282).Single();

            string role = functionstr + @" 
            message = '';
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            port_no = RemoveNull(tmains.port_no);//口岸 
            cabin_no = RemoveNull(tmains.cabin_no) ; //提运单号
            transmode_no = RemoveNull(tmains.transmode_no);//运输方式
            expression1=  declare_id == '1';
            expression2=  port_no == '5316';
            expression3 = expression1 & expression2;
            expression4 = cabin_no.Length !=11;
           
             if(expression3)
             {
                 if(  expression4)
                 {    
                        message +='流水号长度不符或者流水号第2位与大鹏不一致！';
                    return message;
                 }
              expression5 = cabin_no.Substring(1, 1) != '1';
              expression6 = transmode_no  != '2';
              expression7 = expression4 | expression5 | expression6;
               
                if(expression7)
                    message +='流水号长度不符或者流水号第2位与大鹏不一致！';
             }
             
           
             return message;
             
            ";
            try
            {
                string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);

                Assert.AreEqual(message, "流水号长度不符或者流水号第2位与大鹏不一致！");
            }
            catch (Exception e)
            {
            }

        }

        /// <summary>
        /// 流水号长度不符或者流水号第3位与蛇口不一致
        /// </summary>
        [TestMethod]
        public void TestLogic2()
        {
            // FL.Entity.DB.t_mains mains = new t_mains();
            var mains = fuliuEntities.t_mains.Where(t => t.id == 883282).Single();
            mains.cabin_no = "12345678910";
            mains.port_no = "5304";
            mains.transmode_no = "2";
            mains.declare_id = 1;

            string role = functionstr + @"
            message = '';
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            port_no = RemoveNull(tmains.port_no);//口岸 
            cabin_no = RemoveNull(tmains.cabin_no) ; //提运单号
            expression1=  declare_id == '1';
            expression2=  port_no == '5304';
            expression3 = expression1 & expression2;
            expression4 = cabin_no.Length !=13;
 
            if(expression3)
            {
                 if(  expression4)
                 {    
                        message +='流水号长度不符或者流水号第3位与蛇口不一致！';
                    return message;
                 }

                expression5 = cabin_no.Substring(2, 1) < '2';
                expression6 =  cabin_no.Substring(2, 1) > '5';
                expression7 = expression4 | expression5 | expression6;
                if(expression7)
                message +='流水号长度不符或者流水号第3位与蛇口不一致！';
            }
           
           return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "流水号长度不符或者流水号第3位与蛇口不一致！");
        }

        /// <summary>
        /// 流水号长度不符或者流水号第3位与深关前海不一致！
        /// </summary>
        [TestMethod]
        public void TestLogic3()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.cabin_no = "12345678910";
            mains.port_no = "5304";
            mains.transmode_no = "2";
            mains.declare_id = 1;

            string role = functionstr + @"
            message = '';
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            port_no = RemoveNull(tmains.port_no);//口岸 
            cabin_no = RemoveNull(tmains.cabin_no) ; //提运单号
            expression1=  declare_id == '1';
            expression2=  port_no == '5349';
            expression3 = expression1 & expression2;
            expression4 = cabin_no.Length !=13;
            if(expression3)
            {
                   if(  expression4)
                 {    
                        message +='流水号长度不符或者流水号第3位与深关前海不一致！！';
                    return message;
                 }
             expression5 = cabin_no.Substring(2, 1) !='8';
            expression6 = expression4 | expression5 ;
                if(expression6)
                message +='流水号长度不符或者流水号第3位与深关前海不一致！！';
             }
            return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "流水号长度不符或者流水号第3位与深关前海不一致！！");
        }

        /// <summary>
        /// 逻辑校验 4  一般贸易对应的征免方式不能是全免
        /// </summary>
        [TestMethod]
        public void TestLogic4()
        {
            //FL.Entity.DB.t_mains mains = new t_mains();
            //mains.trade_no = "0110";
            ////mains.impose_no = "123142243";  //征免方式  t_goods_details

            //List<t_goods_details> goodslist = new List<t_goods_details>();
            //t_goods_details goods = new t_goods_details();
            //goods.impose_no = "3";
            //goodslist.Add(goods);

            //t_goods_details goods2 = new t_goods_details();
            //goods2.impose_no = "3";
            //goodslist.Add(goods2);
            try
            {


                t_mains mains = fuliuEntities.t_mains.Where(t => t.id == 880826).SingleOrDefault();
                List<t_goods_details> goodslist = fuliuEntities.t_goods_details.Where(t => t.t_main_id == mains.id).ToList();

                string role = functionstr + @"
            message = '';
            trade_no =   RemoveNull(tmains.trade_no); //贸易方式
           
           
            if(trade_no == '0110' )
            {
               foreach (goods in goodslist) 
               {
                      if(goods.impose_no == '3'){
                          message +='一般贸易对应的征免方式不能是全免！';
                          break;
                       }
               }
            }
           return message;
            ";
                string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
                Assert.AreEqual(message, "一般贸易对应的征免方式不能是全免！");
            }
            catch (Exception e)
            {

            }
        }

        /// <summary>
        /// 逻辑校验 5  进料对口与来料加工对应的征免方式不能是照章！
        /// </summary>
        [TestMethod]
        public void TestLogic5()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.trade_no = "0615";
            //mains.impose_no = "123142243";  //征免方式  t_goods_details

            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.impose_no = "3";
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.impose_no = "1";
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
            trade_no =   RemoveNull(tmains.trade_no); //贸易方式
            if(trade_no == '0615' | trade_no == '0214' )
            {
               foreach (goods in goodslist) 
               {
                      if(goods.impose_no == '1'){
                          message +='进料对口与来料加工对应的征免方式不能是照章！！';
                          break;
                       }
               }
            }
           return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "进料对口与来料加工对应的征免方式不能是照章！！");
        }

        /// <summary>
        /// 逻辑校验 6  进料成品退换与来料成品退换对应的征免性质应为空！
        /// </summary>
        [TestMethod]
        public void TestLogic6()
        {
            //  FL.Entity.DB.t_mains mains = new t_mains();
            t_mains mains = fuliuEntities.t_mains.Where(m => m.id == 869963).Single();
            mains.trade_no = "4600";
            mains.imposemode_no = "";

            string role = functionstr + @"
            message = '';
            trade_no =   RemoveNull(tmains.trade_no); //贸易方式
            imposemode_no = RemoveNull(tmains.imposemode_no);//征免 性质
           
            if((trade_no == '4600' | trade_no == '4400') & imposemode_no.Length != 0)
            {
               message +='进料成品退换与来料成品退换对应的征免性质应为空！';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "进料成品退换与来料成品退换对应的征免性质应为空！");
        }

        /// <summary>
        /// 逻辑校验 7  出口运抵国与目的国不一致！
        /// </summary>
        [TestMethod]
        public void TestLogic7()
        {
            //FL.Entity.DB.t_mains mains = new t_mains();
            //mains.declare_id = 1;//进出口
            //mains.start_country_no = "sss";//运抵国

            //List<t_goods_details> goodslist = new List<t_goods_details>();
            //t_goods_details goods = new t_goods_details();
            //goods.country_no = "ss";//目的国
            //goodslist.Add(goods);
            t_mains tmains = fuliuEntities.t_mains.Where(i => i.id == 880826).Single();
            List<t_goods_details> goodslist = fuliuEntities.t_goods_details.Where(i => i.t_main_id == 880826).ToList();

            string role = functionstr + @"
            message = '';
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            start_country_no = RemoveNull(tmains.start_country_no);//运抵国
           
            if(declare_id == '1')
            {
                   foreach (goods in goodslist) 
               {
                      if(goods.country_no != start_country_no){
                            message +='出口运抵国与目的国不一致！';
                          break;
                       }
               }
             
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(tmains, role, null, goodslist);
            Assert.AreEqual(message, "出口运抵国与目的国不一致！");


        }

        /// <summary>
        /// 逻辑校验 8  目的国不能是中国
        /// </summary>
        [TestMethod]
        public void TestLogic8()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 1;//进出口

            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.country_no = "142";//目的国
            goodslist.Add(goods);

            string role = functionstr + @"
            message = '';
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            
            if(declare_id == '1')
            {
                foreach (goods in goodslist) 
               {
                      if(goods.country_no == '142'){
                            message +='目的国不能是中国！';
                          break;
                       }
               }
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "目的国不能是中国！");
        }

        /// <summary>
        /// 逻辑校验 9  目的国不能是塞尔维亚和黑山
        /// </summary>
        [TestMethod]
        public void TestLogic9()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 1;//进出口

            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.country_no = "349";//目的国
            goodslist.Add(goods);

            string role = functionstr + @"
            message = '';
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            
            if(declare_id == '1')
            {
                foreach (goods in goodslist) 
               {
                      if(goods.country_no == '349'){
                            message +='目的国不能是塞尔维亚和黑山！';
                          break;
                       }
               }
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "目的国不能是塞尔维亚和黑山！");
        }

        /// <summary>
        /// 逻辑校验10  出口国为法属波利尼西亚623时,指运港不能是大洋洲其他国家699
        /// </summary>
        [TestMethod]
        public void TestLogic10()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 1;//进出口
            mains.start_country_no = "623";//运抵国
            mains.loadport_no = "699";//指运港

            string role = functionstr + @"
            message = '';
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            start_country_no =   RemoveNull(tmains.start_country_no); //运抵国
            loadport_no =   RemoveNull(tmains.loadport_no); //指运港
            
            if(declare_id == '1' & start_country_no == '623' & loadport_no == '699')
            {
                 message +='出口国为法属波利尼西亚623时,指运港不能是大洋洲其他国家699！';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "出口国为法属波利尼西亚623时,指运港不能是大洋洲其他国家699！");
        }

        /// <summary>
        /// 逻辑校验11 出口成交方式为CIF，运保费不能为空！
        /// </summary>
        [TestMethod]
        public void TestLogic11()
        {
            //FL.Entity.DB.t_mains mains = new t_mains();
            //mains.declare_id = 1;//进出口
            //mains.bargainmode_no = "1";//成交方式
            //mains.freightmode_no = "";//运费1
            //mains.freight = null;//运费2
            //mains.freight_currency_no = "";//运费3
            //mains.subscribemode_no = "";//保费1
            //mains.subscribe = 2;//保费2
            //mains.subscribe_currency_no = "";//保费3

            var mains = fuliuEntities.t_mains.Where(s => s.id == 876235).Single();

            string role = functionstr + @"
            message = '';
		    declare_id =   RemoveNull(tmains.declare_id); //进出口
            bargainmode_no =   RemoveNull(tmains.bargainmode_no); //成交方式
            freightmode_no =   RemoveNull(tmains.freightmode_no); //运费1
            freight =  (double) DigitalRemoveNull(tmains.freight); //运费2
            freight_currency_no =   RemoveNull(tmains.freight_currency_no); //运费3
            subscribemode_no =   RemoveNull(tmains.subscribemode_no); //保费1
            subscribe =   (double) DigitalRemoveNull(tmains.subscribe); //保费2
            subscribe_currency_no =   RemoveNull(tmains.subscribe_currency_no); //保费3
             //  1率            

            if(declare_id == '1'  &  bargainmode_no== '1')  
            {
                    if (freightmode_no.Trim().Length  == 0    | subscribemode_no.Trim().Length == 0 )
                   { 
                       message +='出口成交方式为CIF，运保费不能为空！';
                   }
                    if (
                         ( freightmode_no.Trim()   == 1  & freight  == 0 )
                        | (subscribemode_no.Trim()== 1  & subscribe  == 0 )
                    )
                    { 
                       message +='出口成交方式为CIF，运保费不能为空！';
                    }
                    if (
                      ( (freightmode_no.Trim()   == 2 | freightmode_no.Trim()   == 3 ) & (freight  == 0  |  freight_currency_no.Trim().Length == 0))
                     |( (subscribemode_no.Trim()== 2 |  freightmode_no.Trim()   == 3) & (subscribe  == 0  |  subscribe_currency_no.Trim().Length == 0))
                    )
                    { 
                      message +='出口成交方式为CIF，运保费不能为空！';
                    }
            } 
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "出口成交方式为CIF，运保费不能为空！");
        }

        /// <summary>
        /// 逻辑校验12 出口成交方式为C&F，运费不能为空！
        /// </summary>
        [TestMethod]
        public void TestLogic12()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 1;//进出口
            mains.bargainmode_no = "1";//成交方式
            mains.freightmode_no = "2";//运费1
            mains.freight = null;//运费2
            mains.freight_currency_no = "1";//运费3

            string role = functionstr + @"
            message = '';
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            bargainmode_no =   RemoveNull(tmains.bargainmode_no); //成交方式
            freightmode_no =   RemoveNull(tmains.freightmode_no); //运费1
            freight =   (double) DigitalRemoveNull(tmains.freight); //运费2
            freight_currency_no =   RemoveNull(tmains.freight_currency_no); //运费3
           
            if(declare_id == '1'  &  bargainmode_no== '2'  &  
           (freightmode_no.Length == 0  | freight == 0 |  freight_currency_no.Length == 0)
             )
            {
                 message +='出口成交方式为C&F，运费不能为空！';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "出口成交方式为C&F，运费不能为空！");
        }

        /// <summary>
        /// 逻辑校验13 净重为空或者净重大于毛重！
        /// </summary>
        [TestMethod]
        public void TestLogic13()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.netweight = 8;//净重
            mains.grossweight = 6;//毛重

            string role = functionstr + @"
            message = '';
             
            netweight =  (double) DigitalRemoveNull(tmains.netweight); //净重
            grossweight =  (double) DigitalRemoveNull(tmains.grossweight); //毛重
         
            if( netweight ==0 || netweight > grossweight )
            {
                 message +='净重为空或者净重大于毛重！';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "净重为空或者净重大于毛重！");
        }

        /// <summary>
        /// 逻辑校验14 对应ID 16 报关单表体净重#{合计("成交数量"){|i|i.unit_no.to_s.rstrip=="035"}+合计("法定数量"){|i|i.unit_no.to_s.rstrip!="035"&&i.unit02_no.to_s.rstrip=="035"}+合计("第二数量"){|i|i.unit_no.to_s.rstrip!="035"&&i.unit02_no.to_s.rstrip!="035"&&i.unit03_no.to_s.rstrip=="035"}}与表头净重#{值("净重")}不符,相差#{合计("成交数量"){|i|i.unit_no.to_s.rstrip=="035"}+合计("法定数量"){|i|i.unit_no.to_s.rstrip!="035"&&i.unit02_no.to_s.rstrip=="035"}+合计("第二数量"){|i|i.unit_no.to_s.rstrip!="035"&&i.unit02_no.to_s.rstrip!="035"&&i.unit03_no.to_s.rstrip=="035"} - 值("净重").to_f}
        /// </summary>
        [TestMethod]
        public void TestLogic14()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.netweight = 54;//净重
            List<t_goods_details> goodslist = new List<t_goods_details>();
            var goods = new t_goods_details();
            goods.unit_no = "035";
            goods.unit02_no = "035";
            goods.unit03_no = "035";
            goods.amount = 8;//成交数量
            goods.amount02 = 1;//法定数量
            goods.amount03 = 1;//第二数量
            goodslist.Add(goods);
            var goods2 = new t_goods_details();
            goods2.unit_no = "035";
            goods2.unit02_no = "035";
            goods2.unit03_no = "035";
            goods2.amount = 50;//成交数量
            goods2.amount02 = 1;//法定数量
            goods2.amount03 = 1;//第二数量
            goodslist.Add(goods2);

            try
            {
                //var mains = fuliuEntities.t_mains.Where(t => t.id == 906557).Single();
                //var goodslist = fuliuEntities.t_goods_details.Where(t => t.t_main_id == 906557).ToList();
                string role = functionstr + @"
            message = '';
       aa=tmains.netweight;
        netweight =double.Parse(aa)   ; //净重
   
            amount =0d;
            amount02=0d;
            amount03=0d;

//               foreach (goods in goodslist) 
//               {
//                      if(goods.unit_no == '035'){
//                            amount+=(double)DigitalRemoveNull(goods.amount) ;
//                       }
//                       if(goods.unit_no != '035' & goods.unit02_no == '035'){
//                            amount02+=(double)DigitalRemoveNull(goods.amount02) ; 
//                       }
//                       if(goods.unit_no != '035' & goods.unit02_no != '035'& goods.unit03_no == '035'){
//                            amount03+=(double)DigitalRemoveNull(goods.amount03) ; 
//                       }
//               }
////             total = amount+amount02+amount03;
//             if(total >0 & total != netweight){
//               message +=  string.Format('报关单表体净重合计{0} 与表头净重{1}不符 相差{2} ',total,netweight,total-netweight );
//             }
             message=netweight;
             return message;
            ";
                string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
                Assert.AreEqual(message, "报关单表体净重合计58 与表头净重54不符 相差4 ");
            }
            catch (Exception e)
            {
            }

        }

        /// <summary>
        /// 逻辑校验15 对应id 17 报关单表体币制不符！
        /// </summary>
        [TestMethod]
        public void TestLogic15()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.netweight = 54;//净重
            List<t_goods_details> goodslist = new List<t_goods_details>();
            var goods = new t_goods_details();
            goods.currency_no = "035";
            goodslist.Add(goods);
            var goods2 = new t_goods_details();
            goods2.currency_no = "05";
            goodslist.Add(goods2);

            var goods3 = new t_goods_details();
            goods3.currency_no = "035";
            goodslist.Add(goods3);

            string role = functionstr + @"
            message = '';
            currency_no ='';
            if(goodslist.Count >0)
            currency_no = RemoveNull(goodslist[0].currency_no);

               foreach (goods in goodslist) 
               {
                    goodscurrency_no =  RemoveNull(goods.currency_no);
                    if(goodscurrency_no != currency_no){
                          num_no = goods.num_no;
                         message += string.Format('商品编码{0}币制与报关单表体币制不符！',num_no);
                    }
                    currency_no = goodscurrency_no;
               }
             
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "报关单表体币制不符！");
        }

        /// <summary>
        ///逻辑校验16 对应ID 18 报关单表体征免方式不符！
        /// </summary>
        [TestMethod]
        public void TestLogic16()
        {

            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            var goods = new t_goods_details();
            goods.impose_no = "035";
            goodslist.Add(goods);
            var goods2 = new t_goods_details();
            goods2.impose_no = "03";
            goodslist.Add(goods2);

            var goods3 = new t_goods_details();
            goods3.impose_no = "035";
            goodslist.Add(goods3);

            string role = functionstr + @"
               message = '';
               impose_no ='';

               if(goodslist.Count >0)
                 impose_no = RemoveNull(goodslist[0].impose_no);

               foreach (goods in goodslist) 
               {
                      goodsimpose_no =  RemoveNull(goods.impose_no);
                    if(goodsimpose_no != impose_no){
                         num_no = goods.num_no;
                         message += string.Format('商品{0}征免方式与报关单表体征免方式不符！',num_no);
                    }
                    impose_no =goodsimpose_no;
               }
             
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "报关单表体征免方式不符！");

        }

        /// <summary>
        ///逻辑校验17 对应id 19 柜型柜数与重量逻辑不符！单柜平均 #{值("毛重").to_f / (数量("柜"){|d| d.id > 0})}
        /// </summary>
        [TestMethod]
        public void TestLogic17()
        {
            try
            {
                FL.Entity.DB.t_mains mains = fuliuEntities.t_mains.Where(t => t.id == 924211).SingleOrDefault();

                List<t_details> details = new List<t_details>();
                //mains.transmode_no = "2";//运输方式
                //mains.grossweight = 2000230;//
                //List<t_goods_details> goodslist = new List<t_goods_details>();
                //List<t_details> detailslist = new List<t_details>();
                //t_details details = new t_details();
                //details.container_type_no = "20";
                //detailslist.Add(details);

                //t_details details2 = new t_details();
                //details2.container_type_no = "40";
                //detailslist.Add(details2);
                //var b= double.Parse();
                string role = functionstr + @"
            message = '';
            transmode_no = DigitalRemoveNull(tmains.transmode_no); //运输方式  
            grossweight =tmains.grossweight; //毛重  ;
               total =0;
            count =0;  

              if(transmode_no!=2)//只校验水路运输
                     return message;
               foreach (details in detailslist) 
               {
                    if(details.container_type_no == '20' ){
                          total +=17500;
                    }
                    if(details.container_type_no == '40' ){
                          total +=22000;
                    }
                    count = count+1;
               }

             
                avg=  0;
                if(count!=0)  
                avg=grossweight/count;
      
             if( grossweight >20000 & transmode_no == '2' & grossweight  > total) 
                message +=string.Format('柜型柜数与重量逻辑不符！单柜平均 {0}  ',avg);
             return message;
            ";

                string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, null, details);
                Assert.AreEqual(message, "柜型柜数与重量逻辑不符！单柜平均 1000115  ");

            }
            catch (Exception e)
            {

                throw;
            }



        }


        /// <summary>
        ///逻辑校验18 对应ID 22 通关单号必须是18位！
        /// </summary>
        [TestMethod]
        public void TestLogic18()
        {
            t_mains mains = fuliuEntities.t_mains.Where(i => i.id == 997807).Single();
            List<t_accompany_details> accompanylist = fuliuEntities.t_accompany_details.Where(t => t.t_main_id == mains.id).ToList();//随附单据


            string role = functionstr + @"
            message = '';
             
            foreach (accompany in accompanylist) 
            {
               if(accompany.control_no == 'B' & accompany.accompany_no.Length !=18 )  
                 message +='通关单号必须是18位！';
               if(accompany.control_no == 'A' & accompany.accompany_no.Length !=18 )  
                                message +='通关单号必须是18位！';
            }
            return message;
            ";
            try
            {
                string clearanceState = FL.RuleEngine.Core.RoleRuntimeHost.CheckClearanceState(mains.id,
                (int)mains.declare_id, mains.tgdstatus);
                string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, null, null, accompanylist, null, null);
                //  string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, null, null);

                Assert.AreEqual(message, "通关单号必须是18位！");
            }
            catch (Exception e)
            {
            }

        }

        /// <summary>
        ///逻辑校验19 对应ID 23 提运单号必须是13位！
        /// </summary>
        [TestMethod]
        public void TestLogic19()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 2;//进出口
            mains.cabin_no = "a";//提运单号
            mains.port_no = "5301";//口岸


            FL.Entity.DB.t_mains mains2 = new t_mains();
            mains2.declare_id = 2;//进出口
            mains2.cabin_no = "djfhdjswjdjfh";//提运单号
            mains2.port_no = "5301";//口岸

            string role = functionstr + @"
            message = '';
            port_no = RemoveNull(tmains.port_no); //口岸  
            declare_id = DigitalRemoveNull(tmains.declare_id); //进出口
            cabin_no = RemoveNull(tmains.cabin_no); //提运单号
            if((port_no=='5301'| port_no=='5320') & declare_id=='2'& cabin_no.Length !=13)
               message +='提运单号必须是13位！';
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "提运单号必须是13位！");

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains2, role, null);
            Assert.AreEqual(message2, "");
        }


        /// <summary>
        ///逻辑校验20  ID 24运输工具格式错误！  还需找水哥沟通
        /// </summary>
        [TestMethod]
        public void TestLogic20()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.transname = "a";//运输工具
            mains.port_no = "5301";//口岸
            string role = functionstr + @"
            message = '';
            port_no = RemoveNull(tmains.port_no); //口岸  
            transname = DigitalRemoveNull(tmains.transname); //运输工具
            regex = new Regex(@'^粤Z[A-Z]{2}[0-9]{2}港 \/提前报关$');
 
            exp1= (port_no=='5301'| port_no=='5320');
            exp2 = transname.Length >0 && !regex.IsMatch(transname);
            if( exp1 & exp2 )
               message +='运输工具格式错误！';
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "运输工具格式错误！");
        }

        /// <summary>
        ///逻辑校验21 ID 35 进口时用途必须输入用途！
        /// </summary>
        [TestMethod]
        public void TestLogic21()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 2;//进出口
            mains.factory = null;//用途

            string role = functionstr + @"
            message = '';
            factory = RemoveNull(tmains.factory); //用途
            declare_id = DigitalRemoveNull(tmains.declare_id);//进出口

            if( declare_id == '2' & factory.Trim().Length == 0 )
               message +='进口时用途必须输入用途！';
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "进口时用途必须输入用途！");

            FL.Entity.DB.t_mains mains2 = new t_mains();
            mains2.declare_id = 2;//进出口
            mains2.factory = "asdf";//用途

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains2, role, null);
            Assert.AreEqual(message2, "");

        }

        /// <summary>
        ///逻辑校验22 ID 39 成交单位和法定单位一致时，成交数量和法定数量必须相同！
        /// </summary>
        [TestMethod]
        public void TestLogic22()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 2;//进出口
            mains.factory = null;//用途

            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "142";
            goods.unit02_no = "142";
            goods.amount = 4;
            goods.amount02 = 4;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.unit_no = "143";
            goods2.unit02_no = "143";
            goods2.amount = 4;
            goods2.amount02 = 4;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); //成交单位
                unit02_no= RemoveNull(goods.unit02_no); //成交单位
                amount= DigitalRemoveNull(goods.amount); //成交单位
                amount02= DigitalRemoveNull(goods.amount02); //成交单位
                if(unit_no == unit02_no & amount != amount02){
                    message +='成交单位和法定单位一致时，成交数量和法定数量必须相同！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit_no = "143";
            goods3.unit02_no = "143";
            goods3.amount = 4;
            goods3.amount02 = 5;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "成交单位和法定单位一致时，成交数量和法定数量必须相同！");
        }

        /// <summary>
        ///逻辑校验23 40 成交单位和第二单位一致时，成交数量和第二数量必须相同！
        /// </summary>
        [TestMethod]
        public void TestLogic23()
        {
            FL.Entity.DB.t_mains mains = new t_mains();


            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "142";
            goods.unit03_no = "142";
            goods.amount = 4;
            goods.amount03 = 4;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.unit_no = "143";
            goods2.unit03_no = "143";
            goods2.amount = 4;
            goods2.amount03 = 4;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); //成交单位
                unit03_no= RemoveNull(goods.unit03_no); //成交单位
                amount= DigitalRemoveNull(goods.amount); //成交单位
                amount03= DigitalRemoveNull(goods.amount03); //成交单位
                if(unit_no == unit03_no & amount != amount03){
                    message +='成交单位和第二单位一致时，成交数量和第二数量必须相同！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit_no = "143";
            goods3.unit03_no = "143";
            goods3.amount = 4;
            goods3.amount03 = 5;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "成交单位和第二单位一致时，成交数量和第二数量必须相同！");
        }


        /// <summary>
        ///逻辑校验24 ID 41成交单位为个和法定单位为千个，成交数量必须等于法定数量*1000！
        /// </summary>
        [TestMethod]
        public void TestLogic24()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "007";
            goods.unit02_no = "054";
            goods.amount = 4000;
            goods.amount02 = 4;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.unit_no = "007";
            goods2.unit02_no = "054";
            goods2.amount = 2000;
            goods2.amount02 = 2;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); //成交单位
                unit02_no= RemoveNull(goods.unit02_no); //成交单位
                amount= (double)DigitalRemoveNull(goods.amount); //成交单位
                amount02= (double)DigitalRemoveNull(goods.amount02); //成交单位
                if(unit_no == '007' & unit02_no == '054' &  amount !=  amount02 * 1000){
                    message += '成交单位为个和法定单位为千个，成交数量必须等于法定数量*1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            //Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit_no = "007";
            goods3.unit02_no = "054";
            goods3.amount = 4;
            goods3.amount02 = 400;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "成交单位为个和法定单位为千个，成交数量必须等于法定数量*1000！");
        }


        /// <summary>
        ///逻辑校验25  ID 42 成交单位为个和第二单位为千个，成交数量必须等于第二数量*1000！
        /// </summary>
        [TestMethod]
        public void TestLogic25()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "007";
            goods.unit03_no = "054";
            goods.amount = 4000;
            goods.amount03 = 4;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.unit_no = "007";
            goods2.unit03_no = "054";
            goods2.amount = 2000;
            goods2.amount03 = 2;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); //成交单位
                unit03_no= RemoveNull(goods.unit03_no); //成交单位
                amount= (double)DigitalRemoveNull(goods.amount); //成交单位
                amount03= (double)DigitalRemoveNull(goods.amount03); //成交单位
                if(unit_no == '007' & unit03_no == '054' &  amount !=  amount03 * 1000){
                    message += '成交单位为个和第二单位为千个，成交数量必须等于第二数量*1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            //Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit_no = "007";
            goods3.unit03_no = "054";
            goods3.amount = 4;
            goods3.amount03 = 400;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "成交单位为个和第二单位为千个，成交数量必须等于第二数量*1000！");
        }

        /// <summary>
        ///逻辑校验26   ID 43 法定单位和第二单位一致时，法定数量和第二数量必须相同！
        /// </summary>
        [TestMethod]
        public void TestLogic26()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit02_no = "001";
            goods.unit03_no = "001";
            goods.amount02 = 200;
            goods.amount03 = 200;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.unit02_no = "002";
            goods2.unit03_no = "002";
            goods2.amount02 = 2000;
            goods2.amount03 = 2000;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit02_no= RemoveNull(goods.unit02_no);  
                unit03_no= RemoveNull(goods.unit03_no);  
                amount02= (double)DigitalRemoveNull(goods.amount02);  
                amount03= (double)DigitalRemoveNull(goods.amount03);  
                if(unit02_no == unit03_no &  amount02 !=  amount03 ){
                    message += '法定单位和第二单位一致时，法定数量和第二数量必须相同！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            //Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit02_no = "003";
            goods3.unit03_no = "003";
            goods3.amount02 = 4;
            goods3.amount03 = 400;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "法定单位和第二单位一致时，法定数量和第二数量必须相同！");
        }


        /// <summary>
        ///逻辑校验27 ID 44 法定单位为个和第二单位为千个，法定数量必须等于第二数量*1000！
        /// </summary>
        [TestMethod]
        public void TestLogic27()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit02_no = "007";
            goods.unit03_no = "054";
            goods.amount02 = 4000;
            goods.amount03 = 4;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.unit02_no = "007";
            goods2.unit03_no = "054";
            goods2.amount02 = 2000;
            goods2.amount03 = 2;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit02_no= RemoveNull(goods.unit02_no); //成交单位
                unit03_no= RemoveNull(goods.unit03_no); //成交单位
                amount02= (double)DigitalRemoveNull(goods.amount02); //成交单位
                amount03= (double)DigitalRemoveNull(goods.amount03); //成交单位
                if(unit02_no == '007' & unit03_no == '054' &  amount02 !=  amount03 * 1000){
                    message += '法定单位为个和第二单位为千个，法定数量必须等于第二数量*1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            //Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit02_no = "007";
            goods3.unit03_no = "054";
            goods3.amount02 = 4;
            goods3.amount03 = 400;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "法定单位为个和第二单位为千个，法定数量必须等于第二数量*1000！");
        }

        /// <summary>
        ///逻辑校验28  ID 45 成交单位为克和法定单位为千克，成交数量必须等于法定数量*1000！
        /// </summary>
        [TestMethod]
        public void TestLogic28()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "036";
            goods.unit02_no = "035";
            goods.amount = 4000;
            goods.amount02 = 4;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods.unit_no = "036";
            goods.unit02_no = "035";
            goods2.amount = 2000;
            goods2.amount02 = 2;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); //成交单位
                unit02_no= RemoveNull(goods.unit02_no); //成交单位
                amount= (double)DigitalRemoveNull(goods.amount); //成交单位
                amount02= (double)DigitalRemoveNull(goods.amount02); //成交单位
                if(unit_no == '036' & unit02_no == '035' &  amount !=  amount02 * 1000){
                    message += '成交单位为克和法定单位为千克，成交数量必须等于法定数量*1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit_no = "036";
            goods3.unit02_no = "035";
            goods3.amount = 4;
            goods3.amount02 = 400;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "成交单位为克和法定单位为千克，成交数量必须等于法定数量*1000！");
        }

        /// <summary>
        ///逻辑校验29  ID 46 成交单位为克和第二单位为千克，成交数量必须等于第二数量*1000！
        /// </summary>
        [TestMethod]
        public void TestLogic29()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "036";
            goods.unit03_no = "035";
            goods.amount = 4000;
            goods.amount03 = 4;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods.unit_no = "036";
            goods.unit03_no = "035";
            goods2.amount = 2000;
            goods2.amount03 = 2;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); //成交单位
                unit03_no= RemoveNull(goods.unit03_no); //成交单位
                amount= (double)DigitalRemoveNull(goods.amount); //成交单位
                amount03= (double)DigitalRemoveNull(goods.amount03); //成交单位
                if(unit_no == '036' & unit03_no == '035' &  amount !=  amount03 * 1000){
                    message += '成交单位为克和第二单位为千克，成交数量必须等于第二数量*1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit_no = "036";
            goods3.unit03_no = "035";
            goods3.amount = 4;
            goods3.amount03 = 400;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "成交单位为克和第二单位为千克，成交数量必须等于第二数量*1000！");
        }

        /// <summary>
        ///逻辑校验30  ID 47   法定单位为克和第二单位为千克，法定数量必须等于第二数量*1000！
        /// </summary>
        [TestMethod]
        public void TestLogic30()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit02_no = "036";
            goods.unit03_no = "035";
            goods.amount02 = 4000;
            goods.amount03 = 4;

            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods.unit02_no = "036";
            goods.unit03_no = "035";
            goods2.amount02 = 2000;
            goods2.amount03 = 2;

            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit02_no= RemoveNull(goods.unit02_no); //成交单位
                unit03_no= RemoveNull(goods.unit03_no); //成交单位
                amount02= (double)DigitalRemoveNull(goods.amount02); //成交单位
                amount03= (double)DigitalRemoveNull(goods.amount03); //成交单位
                if(unit02_no == '036' & unit03_no == '035' &  amount02 !=  amount03 * 1000){
                    message += '法定单位为克和第二单位为千克，法定数量必须等于第二数量*1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit02_no = "036";
            goods3.unit03_no = "035";
            goods3.amount02 = 4;
            goods3.amount03 = 400;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "法定单位为克和第二单位为千克，法定数量必须等于第二数量*1000！");
        }


        /// <summary>
        ///逻辑校验31 ID 48  成交单位为千个和法定单位为个，成交数量必须等于法定数量/1000！
        /// </summary>
        [TestMethod]
        public void TestLogic31()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "054";
            goods.unit02_no = "007";
            goods.amount = 4;
            goods.amount02 = 4000;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods.unit_no = "054";
            goods.unit02_no = "007";
            goods2.amount = 2;
            goods2.amount02 = 2000;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); //成交单位
                unit02_no= RemoveNull(goods.unit02_no); //成交单位
                amount= (double)DigitalRemoveNull(goods.amount); //成交单位
                amount02= (double)DigitalRemoveNull(goods.amount02); //成交单位
                if(unit_no == '054' & unit02_no == '007' & amount02 !=   amount * 1000){
                    message += '成交单位为千个和法定单位为个，成交数量必须等于法定数量/1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit_no = "054";
            goods3.unit02_no = "007";
            goods3.amount = 4;
            goods3.amount02 = 400;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "成交单位为千个和法定单位为个，成交数量必须等于法定数量/1000！");
        }


        /// <summary>
        ///逻辑校验32   ID 49 成交单位为千个和第二单位为个，成交数量必须等于第二数量/1000！
        /// </summary>
        [TestMethod]
        public void TestLogic32()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "054";
            goods.unit03_no = "007";
            goods.amount = 4;
            goods.amount03 = 4000;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods.unit_no = "054";
            goods.unit03_no = "007";
            goods2.amount = 2;
            goods2.amount03 = 2000;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); //成交单位
                unit03_no= RemoveNull(goods.unit03_no); //成交单位
                amount= (double)DigitalRemoveNull(goods.amount); //成交单位
                amount03= (double)DigitalRemoveNull(goods.amount03); //成交单位
                if(unit_no == '054' & unit03_no == '007' & amount03 !=   amount * 1000){
                    message += '成交单位为千个和第二单位为个，成交数量必须等于第二数量/1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit_no = "054";
            goods3.unit03_no = "007";
            goods3.amount = 4;
            goods3.amount03 = 400;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "成交单位为千个和第二单位为个，成交数量必须等于第二数量/1000！");
        }

        /// <summary>
        ///逻辑校验33  ID 50   法定单位为千个和第二单位为个，法定数量必须等于第二数量/1000！
        /// </summary>
        [TestMethod]
        public void TestLogic33()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit02_no = "054";
            goods.unit03_no = "007";
            goods.amount02 = 4;
            goods.amount03 = 4000;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods.unit02_no = "054";
            goods.unit03_no = "007";
            goods2.amount02 = 2;
            goods2.amount03 = 2000;
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit02_no= RemoveNull(goods.unit02_no);  
                unit03_no= RemoveNull(goods.unit03_no);  
                amount02= (double)DigitalRemoveNull(goods.amount02);  
                amount03= (double)DigitalRemoveNull(goods.amount03); 
                if(unit02_no == '054' & unit03_no == '007' & amount03 !=   amount02 * 1000){
                    message += '法定单位为千个和第二单位为个，法定数量必须等于第二数量/1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit02_no = "054";
            goods3.unit03_no = "007";
            goods3.amount02 = 4;
            goods3.amount03 = 400;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "法定单位为千个和第二单位为个，法定数量必须等于第二数量/1000！");
        }

        /// <summary>
        ///逻辑校验34  ID 51 成交单位为千克和法定单位为克，成交数量必须等于法定数量/1000！
        /// </summary>
        [TestMethod]
        public void TestLogic34()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "035";
            goods.unit02_no = "036";
            goods.amount = 4;
            goods.amount02 = 4000;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.unit_no = "035";
            goods2.unit02_no = "036";
            goods2.amount = 3;
            goods2.amount02 = 3000;
            goodslist.Add(goods2);


            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); 
                unit02_no= RemoveNull(goods.unit02_no); 
                amount= (double)DigitalRemoveNull(goods.amount); 
                amount02= (double)DigitalRemoveNull(goods.amount02);  
                if(unit_no == '035' & unit02_no == '036' & amount02 != amount   * 1000){
                    message += '成交单位为千克和法定单位为克，成交数量必须等于法定数量/1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit_no = "035";
            goods3.unit02_no = "036";
            goods3.amount = 32;
            goods3.amount02 = 3000;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "成交单位为千克和法定单位为克，成交数量必须等于法定数量/1000！");
        }


        /// <summary>
        ///逻辑校验35 ID 52  成交单位为千克和第二单位为克，成交数量必须等于第二数量/1000！
        /// </summary>
        [TestMethod]
        public void TestLogic35()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "035";
            goods.unit03_no = "036";
            goods.amount = 4;
            goods.amount03 = 4000;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.unit_no = "035";
            goods2.unit03_no = "036";
            goods2.amount = 3;
            goods2.amount03 = 3000;
            goodslist.Add(goods2);


            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); 
                unit03_no= RemoveNull(goods.unit03_no); 
                amount= (double)DigitalRemoveNull(goods.amount); 
                amount03= (double)DigitalRemoveNull(goods.amount03);  
                if(unit_no == '035' & unit03_no == '036' & amount03 != amount   * 1000){
                    message += '成交单位为千克和第二单位为克，成交数量必须等于第二数量/1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit_no = "035";
            goods3.unit03_no = "036";
            goods3.amount = 32;
            goods3.amount03 = 3000;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "成交单位为千克和第二单位为克，成交数量必须等于第二数量/1000！");
        }


        /// <summary>
        ///逻辑校验36  ID 53 法定单位为千克和第二单位为克，法定数量必须等于第二数量/1000！
        /// </summary>
        [TestMethod]
        public void TestLogic36()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit02_no = "035";
            goods.unit03_no = "036";
            goods.amount02 = 4;
            goods.amount03 = 4000;
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.unit02_no = "035";
            goods2.unit03_no = "036";
            goods2.amount02 = 3;
            goods2.amount03 = 3000;
            goodslist.Add(goods2);


            string role = functionstr + @"
            message = '';
           
            foreach (goods in goodslist) 
            {
                unit02_no= RemoveNull(goods.unit02_no); 
                unit03_no= RemoveNull(goods.unit03_no); 
                amount02= (double)DigitalRemoveNull(goods.amount02); 
                amount03= (double)DigitalRemoveNull(goods.amount03);  
                if(unit02_no == '035' & unit03_no == '036' & amount03 != amount02   * 1000){
                    message += '法定单位为千克和第二单位为克，法定数量必须等于第二数量/1000！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            t_goods_details goods3 = new t_goods_details();
            goods3.unit02_no = "035";
            goods3.unit03_no = "036";
            goods3.amount02 = 32;
            goods3.amount03 = 3000;
            goodslist.Add(goods3);

            string message2 = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message2, "法定单位为千克和第二单位为克，法定数量必须等于第二数量/1000！");
        }

        /// <summary>
        ///逻辑校验37 ID 54 成交数量不能为0！
        /// </summary>
        [TestMethod]
        public void TestLogic37()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit_no = "asasdf";
            goods.amount = 3;
            goodslist.Add(goods);

            string role = functionstr + @"
            message = '';
            foreach (goods in goodslist) 
            {
                unit_no= RemoveNull(goods.unit_no); 
                amount= (double)DigitalRemoveNull(goods.amount); 
                if(unit_no != '' & amount == 0){
                    message += '成交数量不能为0！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            goodslist.Clear();
            t_goods_details goods2 = new t_goods_details();
            goods.unit_no = null;
            goods.amount = 2;
            goodslist.Add(goods2);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            goodslist.Clear();
            t_goods_details goods3 = new t_goods_details();
            goods.unit_no = "";
            goods.amount = 3;
            goodslist.Add(goods3);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            goodslist.Clear();
            t_goods_details goods4 = new t_goods_details();
            goods4.unit_no = "asdf";
            goods4.amount = 0;
            goodslist.Add(goods4);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "成交数量不能为0！");

        }

        /// <summary>
        ///逻辑校验38 ID 55  法定数量不能为0！
        /// </summary>
        [TestMethod]
        public void TestLogic38()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit02_no = "asasdf";
            goods.amount02 = 3;
            goodslist.Add(goods);

            string role = functionstr + @"
            message = '';
            foreach (goods in goodslist) 
            {
                unit02_no= RemoveNull(goods.unit02_no); 
                amount02= (double)DigitalRemoveNull(goods.amount02); 
                if(unit02_no != '' & amount02 == 0){
                    message += '法定数量不能为0！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            goodslist.Clear();
            t_goods_details goods2 = new t_goods_details();
            goods.unit02_no = null;
            goods.amount02 = 2;
            goodslist.Add(goods2);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            goodslist.Clear();
            t_goods_details goods3 = new t_goods_details();
            goods.unit02_no = "";
            goods.amount02 = 3;
            goodslist.Add(goods3);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            goodslist.Clear();
            t_goods_details goods4 = new t_goods_details();
            goods4.unit02_no = "asdf";
            goods4.amount02 = 0;
            goodslist.Add(goods4);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "法定数量不能为0！");

        }

        /// <summary>
        ///逻辑校验39 ID 56 第二数量不能为0！
        /// </summary>
        [TestMethod]
        public void TestLogic39()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.unit03_no = "asasdf";
            goods.amount03 = 3;
            goodslist.Add(goods);

            string role = functionstr + @"
            message = '';
            foreach (goods in goodslist) 
            {
                unit03_no= RemoveNull(goods.unit03_no); 
                amount03= (double)DigitalRemoveNull(goods.amount03); 
                if(unit03_no != '' & amount03 == 0){
                    message += '第二数量不能为0！';
                    break;
                }
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            goodslist.Clear();
            t_goods_details goods2 = new t_goods_details();
            goods.unit03_no = null;
            goods.amount03 = 2;
            goodslist.Add(goods2);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            goodslist.Clear();
            t_goods_details goods3 = new t_goods_details();
            goods.unit03_no = "";
            goods.amount03 = 3;
            goodslist.Add(goods3);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

            goodslist.Clear();
            t_goods_details goods4 = new t_goods_details();
            goods4.unit03_no = "asdf";
            goods4.amount03 = 0;
            goodslist.Add(goods4);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "第二数量不能为0！");

        }


        /// <summary>
        ///逻辑校验40 ID 70  进料对口的征免性质必须是进料加工！
        /// </summary>
        [TestMethod]
        public void TestLogic40()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.trade_no = "0615";//贸易方式
            mains.imposemode_no = "asdf";//征免性质
            List<t_goods_details> goodslist = new List<t_goods_details>();

            string role = functionstr + @"
            message = '';
            trade_no =   RemoveNull(tmains.trade_no); //贸易方式
            imposemode_no =   RemoveNull(tmains.imposemode_no); //征免性质
            if(trade_no == '0615' && imposemode_no != '503')
            {
                message += '进料对口的征免性质必须是进料加工！';
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "进料对口的征免性质必须是进料加工！");

            mains.trade_no = "0615";//贸易方式
            mains.imposemode_no = "503";//征免性质
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

        }

        /// <summary>
        ///逻辑校验41  ID 71  来料加工的征免性质必须是来料加工！
        /// </summary>
        [TestMethod]
        public void TestLogic41()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.trade_no = "0214";//贸易方式
            mains.imposemode_no = "asdf";//征免性质
            List<t_goods_details> goodslist = new List<t_goods_details>();

            string role = functionstr + @"
            message = '';
            trade_no =   RemoveNull(tmains.trade_no); //贸易方式
            imposemode_no =   RemoveNull(tmains.imposemode_no); //征免性质
            if(trade_no == '0214' && imposemode_no != '502')
            {
                message += '来料加工的征免性质必须是来料加工！';
            }
            return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "来料加工的征免性质必须是来料加工！");

            mains.trade_no = "0214";//贸易方式
            mains.imposemode_no = "502";//征免性质
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

        }

        /// <summary>
        ///逻辑校验42 ID 72   许可证存在全角数据！
        /// </summary>
        [TestMethod]
        public void TestLogic42()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.licence_no = "021Ａ4";//许可证号
            List<t_goods_details> goodslist = new List<t_goods_details>();

            string role = functionstr + @"
            message = '';
            licence_no =   RemoveNull(tmains.licence_no); //许可证号
             regex = new Regex('[０-９Ａ-Ｚａ-ｚ，。（）　；：、＼－“”’‘！＠＃￥％＆×＋｛｝｜？《》]');
            if( regex.IsMatch(licence_no))
            {
                message += '许可证存在全角数据！';
            }
            return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "许可证存在全角数据！");

            mains.licence_no = "0214";//许可证号
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");
        }


        /// <summary>
        ///逻辑校验43  ID 73  合同协议号存在全角数据！
        /// </summary>
        [TestMethod]
        public void TestLogic43()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.contract_no = "021Ａ4";//合同协议
            List<t_goods_details> goodslist = new List<t_goods_details>();

            string role = functionstr + @"
            message = '';
            contract_no =   RemoveNull(tmains.contract_no); //合同协议
             regex = new Regex('[０-９Ａ-Ｚａ-ｚ，。（）　；：、＼－“”’‘！＠＃￥％＆×＋｛｝｜？《》]');
            if( regex.IsMatch(contract_no))
            {
                message += '合同协议号存在全角数据！';
            }
            return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "合同协议号存在全角数据！");

            mains.contract_no = "0214";//合同协议
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        ///逻辑校验44 ID 74  标记唛码存在全角数据！
        /// </summary>
        [TestMethod]
        public void TestLogic44()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.mark = "021Ａ4";//标记唛码
            List<t_goods_details> goodslist = new List<t_goods_details>();

            string role = functionstr + @"
            message = '';
            mark =   RemoveNull(tmains.mark); //标记唛码
             regex = new Regex('[０-９Ａ-Ｚａ-ｚ，。（）　；：、＼－“”’‘！＠＃￥％＆×＋｛｝｜？《》]');
            if( regex.IsMatch(mark))
            {
                message += '标记唛码存在全角数据！';
            }
            return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "标记唛码存在全角数据！");

            mains.mark = "0214";//标记唛码
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验45 ID 75  序号为 {i} 的商品名称存在全角数据！
        /// </summary>
        [TestMethod]
        public void TestLogic45()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.mark = "";//标记唛码
            List<t_goods_details> goodslist = new List<t_goods_details>();
            var goods = new t_goods_details();
            goods.goods_name = "021Ａ4";
            goods.item_no = "2";
            goodslist.Add(goods);

            string role = functionstr + @"
            message = '';
            regex = new Regex('[０-９Ａ-Ｚａ-ｚ，。（）　；：、＼－“”’‘！＠＃￥％＆×＋｛｝｜？《》]');
             
               foreach (goods in goodslist) 
            {
                goods_name= RemoveNull(goods.goods_name); //商品名称
                if(regex.IsMatch(goods_name)){
                    message += '序号为{'+goods.item_no+'}的商品名称存在全角数据！';
                    break;
                }
            }
            return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "序号为{2}的商品名称存在全角数据！");

            goodslist = new List<t_goods_details>();
            var goods2 = new t_goods_details();
            goods2.goods_name = "0214";
            goods2.item_no = "2";
            goodslist.Add(goods2);

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验46 ID 76  序号为 {i} 的品牌存在全角数据！  目前来看在出口单内没用到商品品牌
        /// </summary>
        [TestMethod]
        public void TestLogic46()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.mark = "";//标记唛码
            List<t_goods_details> goodslist = new List<t_goods_details>();
            var goods = new t_goods_details();
            goods.goods_brand = "021Ａ4";
            goods.item_no = "2";
            goodslist.Add(goods);

            string role = functionstr + @"
            message = '';
            regex = new Regex('[０-９Ａ-Ｚａ-ｚ，。（）　；：、＼－“”’‘！＠＃￥％＆×＋｛｝｜？《》]');
             
               foreach (goods in goodslist) 
            {
                goods_brand= RemoveNull(goods.goods_brand); //商品名称
                if(goods_brand != '' & regex.IsMatch(goods_brand)){
                    message += '序号为{'+goods.item_no+'}的品牌存在全角数据！';
                    break;
                }
            }
            return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "序号为{2}的品牌存在全角数据！");

            goodslist = new List<t_goods_details>();
            var goods2 = new t_goods_details();
            goods2.goods_brand = "0214";
            goods2.item_no = "2";
            goodslist.Add(goods2);

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验47 ID 77   序号为 {i} 的规格存在全角数据！ 
        /// </summary>
        [TestMethod]
        public void TestLogic47()
        {
            //FL.Entity.DB.t_mains mains = new t_mains();
            //mains.mark = "";//标记唛码
            //List<t_goods_details> goodslist = new List<t_goods_details>();
            //var goods = new t_goods_details();
            //goods.goods_spec = "021Ａ4";
            //goods.item_no = "2";
            //goodslist.Add(goods);
            try
            {
                FL.Entity.DB.t_mains mains = fuliuEntities.t_mains.Where(m => m.id == 921561).Single();

                List<t_goods_details> goodslist = fuliuEntities.t_goods_details.Where(t => t.t_main_id == 921561).ToList();
                string role = functionstr + @"
            message = '';
            regex = new Regex('[０-９Ａ-Ｚａ-ｚ，。（）　；：、＼－“”’‘！＠＃￥％＆×＋｛｝｜？《》]');
             
            foreach (goods in goodslist) 
            {
                goods_spec= RemoveNull(goods.goods_spec); //商品名称
                if(goods_spec != '' & regex.IsMatch(goods_spec)){
                    message += '序号为{'+goods.item_no+'}的规格存在全角数据！';
                    break;
                }
            }
            return message;
            ";
                string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
                Assert.AreEqual(message, "序号为{2}的规格存在全角数据！");
            }
            catch (Exception e)
            {

            }


            //goodslist = new List<t_goods_details>();
            //var goods2 = new t_goods_details();
            //goods2.goods_spec = "0214";
            //goods2.item_no = "2";
            //goodslist.Add(goods2);

            //message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            //Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验48 ID 85 存在同名异归类错误！  注释： 同一个报关单 不能存在 【商品名称】【商品编码】 相同 的情况 
        /// </summary>
        [TestMethod]
        public void TestLogic48()
        {
            //0908210000   已磨的豆蔻 880826
            //0908320000  已磨的豆蔻  880901
            t_mains t_main = fuliuEntities.t_mains.Where(i => i.id == 902310).Single();

            string role = functionstr + @"
            message = '';
                if(aaa =1 ){
                    message += '存在同名异归类错误！';
                }
            return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckGoodsNameType(902310);
            string msg = message;
            //            FL.Entity.DB.t_mains mains = new t_mains();
            //            mains.mark = "";//标记唛码
            //            List<t_goods_details> goodslist = new List<t_goods_details>();
            //            var goods = new t_goods_details();
            //            goods.goods_no = "123456";
            //            goods.goods_name = "abc";
            //            goodslist.Add(goods);

            //            var goods2 = new t_goods_details();
            //            goods2.goods_no = "123456";
            //            goods2.goods_name = "abceee";
            //            goodslist.Add(goods2);

            //            string role = functionstr + @"
            //            message = '';
            //                if(goodsnamecount >0 | goodsnocount>0){
            //                    message += '存在同名异归类错误！';
            //                }
            //            return message;
            //            ";
            //            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role);

            //            Assert.AreEqual(message, "存在同名异归类错误！");

            //            goodslist = new List<t_goods_details>();
            //            goods = new t_goods_details();
            //            goods.goods_no = "2";
            //            goods.goods_name = "abc";
            //            goodslist.Add(goods);

            //            goods2 = new t_goods_details();
            //            goods2.goods_no = "123456";
            //            goods2.goods_name = "abc";
            //            goodslist.Add(goods2);
            //            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, goodslist);
            //            Assert.AreEqual(message, "存在同名异归类错误！");

            //            goodslist = new List<t_goods_details>();
            //            goods = new t_goods_details();
            //            goods.goods_no = "2";
            //            goods.goods_name = "abc";
            //            goodslist.Add(goods);

            //            goods2 = new t_goods_details();
            //            goods2.goods_no = "123456";
            //            goods2.goods_name = "abce";
            //            goodslist.Add(goods2);
            //            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, goodslist);
            //            Assert.AreEqual(message, "");
            //0908210000   已磨的豆蔻 880826
            //0908320000  已磨的豆蔻  880901

        }

        /// <summary>
        /// 逻辑校验49 ID 86 进口成交方式为FOB，运保费不能为空！
        /// </summary>
        [TestMethod]
        public void TestLogic49()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 1;//进出口
            mains.bargainmode_no = "1";//成交方式
            mains.freightmode_no = "2";//运费1
            mains.freight = 1;//运费2
            mains.freight_currency_no = "1";//运费3
            mains.subscribemode_no = "2";//保费1
            mains.subscribe = null;//保费2
            mains.subscribe_currency_no = "3";//保费3

            string role = functionstr + @"
            message = '';
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            bargainmode_no =   RemoveNull(tmains.bargainmode_no); //成交方式
            freightmode_no = RemoveNull(tmains.freightmode_no); //运费1
            freight =   (double)DigitalRemoveNull(tmains.freight); //运费2
            freight_currency_no =   RemoveNull(tmains.freight_currency_no); //运费3
            subscribemode_no =   RemoveNull(tmains.subscribemode_no); //保费1
            subscribe =   (double)DigitalRemoveNull(tmains.subscribe); //保费2
            subscribe_currency_no =   RemoveNull(tmains.subscribe_currency_no); //保费3
            
            if(declare_id == '2'  &  bargainmode_no== '3'  &  
          (freightmode_no.Trim().Length == 0  | freight  == 0 |  freight_currency_no.Trim().Length == 0
           | subscribemode_no.Trim().Length == 0  | subscribe == 0 |  subscribe_currency_no.Trim().Length == 0)
             )
            {
                 message +='进口成交方式为FOB，运保费不能为空！';
            }
             return message;
            ";

            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "进口成交方式为FOB，运保费不能为空！");

            mains.declare_id = 1;//进出口
            mains.bargainmode_no = "1";//成交方式
            mains.freightmode_no = "2";//运费1
            mains.freight = 1;//运费2
            mains.freight_currency_no = "1";//运费3
            mains.subscribemode_no = "2";//保费1
            mains.subscribe = 6;//保费2
            mains.subscribe_currency_no = "3";//保费3

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");

        }

        /// <summary>
        /// 逻辑校验50 ID 87   进口成交方式为C&F，保费不能为空！
        /// </summary>
        [TestMethod]
        public void TestLogic50()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 2;//进出口
            mains.bargainmode_no = "3";//成交方式
            mains.subscribemode_no = "2";//保费1
            mains.subscribe = null;//保费2
            mains.subscribe_currency_no = "3";//保费3

            string role = functionstr + @"
            message = '';
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            bargainmode_no =   RemoveNull(tmains.bargainmode_no); //成交方式
            subscribemode_no =   RemoveNull(tmains.subscribemode_no); //保费1
            subscribe =   (double)DigitalRemoveNull(tmains.subscribe); //保费2
            subscribe_currency_no =   RemoveNull(tmains.subscribe_currency_no); //保费3
            if(declare_id == '2'  &  bargainmode_no== '2'  & 
            (subscribemode_no.Trim().Length == 0  | subscribe  == 0 |  subscribe_currency_no.Trim().Length == 0)
             )
            {
                 message +='进口成交方式为C&F，保费不能为空！';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "进口成交方式为C&F，保费不能为空！");
            mains.declare_id = 2;//进出口
            mains.bargainmode_no = "3";//成交方式
            mains.subscribemode_no = "2";//保费1
            mains.subscribe = 6;//保费2
            mains.subscribe_currency_no = "3";//保费3

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");

        }

        /// <summary>
        /// 逻辑校验51 ID 88   为率时金额不能大于1！
        /// </summary>
        [TestMethod]
        public void TestLogic51()
        {
            //FL.Entity.DB.t_mains mains = new t_mains();
            //mains.freightmode_no = "2";//运费1
            //mains.freight = 2;//运费2
            //mains.subscribemode_no = "2";//保费1
            //mains.subscribe = 1;//保费2
            //mains.incidentalmode_no = "2";//杂费1
            //mains.incidental = 1;//杂费2

            var mains = fuliuEntities.t_mains.Where(t => t.id == 881206).Single();
            string role = functionstr + @"
            message ='';
           if(string.IsNullOrEmpty(tmains.bargainmode_no)){
			 return message;
			}
			freightmode_no = 0;

			if(tmains.freightmode_no!=null)
              freightmode_no =   tmains.freightmode_no; //运费1

			freight = 0;
			if(tmains.freight!=null)
              freight =   tmains.freight; //运费2

			  subscribemode_no = 0;
			if(tmains.subscribemode_no!=null)
              subscribemode_no =   tmains.subscribemode_no; //保费1

             subscribe = 0;
			if(tmains.subscribe!=null)
              subscribe =   tmains.subscribe ; //保费2

            incidentalmode_no=0;
            if(tmains.incidentalmode_no!=null)
               incidentalmode_no =tmains.incidentalmode_no; //杂费1

			incidental=0;
            if(tmains.incidental!=null)
               incidental =   tmains.incidental ; //杂费2
           
            if( (freightmode_no ==1 & freight>1) |
                 (subscribemode_no ==1 & subscribe>1) |
                 (incidentalmode_no ==1 & incidental>1)  
             )
            {
                 message +='为率时金额不能大于1！';
            }
   
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            //Assert.AreEqual(message, "为率时金额不能大于1！");
            //mains.freightmode_no = "2";//运费1
            //mains.freight = 1;//运费2
            //mains.subscribemode_no = "2";//保费1
            //mains.subscribe = 1;//保费2
            //mains.incidentalmode_no = "2";//杂费1
            //mains.incidental = (decimal?)0.2;//杂费2

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");

        }

        /// <summary>
        /// 逻辑校验52 ID 89   运费保费杂费单价X数量大于总价了！
        /// </summary>
        [TestMethod]
        public void TestLogic52()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.freightmode_no = "2";//运费1
            mains.freight = 2;//运费2
            mains.subscribemode_no = "2";//保费1
            mains.subscribe = 1;//保费2
            mains.incidentalmode_no = "2";//杂费1
            mains.incidental = 1;//杂费2

            List<t_goods_details> goodslist = new List<t_goods_details>();
            var goods = new t_goods_details();
            goods.amount = 30; //成交数量
            goods.sum = 10;//总价
            goodslist.Add(goods);
            var goods2 = new t_goods_details();
            goods2.amount = 40; //成交数量
            goods2.sum = 30;//总价
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
            freightmode_no =   RemoveNull(tmains.freightmode_no); //运费1
            freight =  (double) DigitalRemoveNull(tmains.freight); //运费2
            subscribemode_no =   RemoveNull(tmains.subscribemode_no); //保费1
            subscribe =  (double) DigitalRemoveNull(tmains.subscribe); //保费2
            incidentalmode_no =   RemoveNull(tmains.incidentalmode_no); //杂费1
            incidental =  (double) DigitalRemoveNull(tmains.incidental); //杂费2
            totalamount =0;// 成交量合计
            totalsum=0;//总价 合计
            foreach (goods in goodslist) 
            {
                damount = DigitalRemoveNull(goods.amount);
                dsum = DigitalRemoveNull(goods.sum);
                totalamount +=  (double)damount;
                totalsum += (double)dsum;  
            }
            if(  (freightmode_no == '2' & freight * totalamount >totalsum) |
                 (subscribemode_no == '2' & subscribe * totalamount >totalsum) |
                 (incidentalmode_no == '2' & incidental * totalamount >totalsum) 
             )
            {
                 message += '运费保费杂费单价X数量大于总价了！';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "运费保费杂费单价X数量大于总价了！");

            mains = new t_mains();
            mains.freightmode_no = "2";//运费1
            mains.freight = 2;//运费2
            mains.subscribemode_no = "2";//保费1
            mains.subscribe = 1;//保费2
            mains.incidentalmode_no = "2";//杂费1
            mains.incidental = 1;//杂费2

            goodslist = new List<t_goods_details>();
            goods = new t_goods_details();
            goods.amount = 30; //成交数量
            goods.sum = 1000;//总价
            goodslist.Add(goods);
            goods2 = new t_goods_details();
            goods2.amount = 40; //成交数量
            goods2.sum = 30;//总价
            goodslist.Add(goods2);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

        }


        /// <summary>
        /// 逻辑校验53 ID 90   运费保费杂费费用大于总价了！
        /// </summary>
        [TestMethod]
        public void TestLogic53()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.freightmode_no = "3";//运费1
            mains.freight = 1000;//运费2
            mains.subscribemode_no = "3";//保费1
            mains.subscribe = 1;//保费2
            mains.incidentalmode_no = "3";//杂费1
            mains.incidental = 1;//杂费2

            List<t_goods_details> goodslist = new List<t_goods_details>();
            var goods = new t_goods_details();
            goods.amount = 30; //成交数量t_main_exts
            goods.sum = 10;//总价
            goodslist.Add(goods);
            var goods2 = new t_goods_details();
            goods2.amount = 40; //成交数量
            goods2.sum = 30;//总价
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
            declare_id =   RemoveNull(tmains.freightmode_no); // 出口
            freightmode_no =   RemoveNull(tmains.freightmode_no); //运费1
            freight =  (double) DigitalRemoveNull(tmains.freight); //运费2
            subscribemode_no =   RemoveNull(tmains.subscribemode_no); //保费1
            subscribe =  (double) DigitalRemoveNull(tmains.subscribe); //保费2
            incidentalmode_no =   RemoveNull(tmains.incidentalmode_no); //杂费1
            incidental =  (double) DigitalRemoveNull(tmains.incidental); //杂费2
           
            totalsum=0;//总价 合计
            foreach (goods in goodslist) 
            {
                dsum = DigitalRemoveNull(goods.sum);
                totalsum += (double)dsum;  
            }
            if(  (freightmode_no == '3' & freight   >=totalsum) |
                 (subscribemode_no == '3' & subscribe  >=totalsum) |
                 (incidentalmode_no == '3' & incidental   >=totalsum) 
             )
            {
                 message += '运费保费杂费费用大于总价了！';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "运费保费杂费费用大于总价了！");

            mains = new t_mains();
            mains.freightmode_no = "3";//运费1
            mains.freight = 2;//运费2
            mains.subscribemode_no = "3";//保费1
            mains.subscribe = 1;//保费2
            mains.incidentalmode_no = "3";//杂费1
            mains.incidental = 1;//杂费2

            goodslist = new List<t_goods_details>();
            goods = new t_goods_details();
            goods.amount = 30; //成交数量
            goods.sum = 1000;//总价
            goodslist.Add(goods);
            goods2 = new t_goods_details();
            goods2.amount = 40; //成交数量
            goods2.sum = 30;//总价
            goodslist.Add(goods2);
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");

        }

        /// <summary>
        /// 逻辑校验54   ID 92  备案号第一位为B的，贸易方式必须是以来开头！
        /// </summary>
        [TestMethod]
        public void TestLogic54()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.records_no = "B";//备案号
            mains.trade_no = "";// 贸易方式

            string role = functionstr + @"
            message = '';
            records_no =   RemoveNull(tmains.records_no); //备案号
            trade_no = RemoveNull(tmainextsinfo['trade_name'] );//贸易方式

            if(records_no.Length>=1){

                if(  records_no.Substring(0, 1) == 'B' & trade_no.Length<1)
                {
                  message += '备案号第一位为B的，贸易方式必须是以来开头！';
                }
                if( records_no.Substring(0, 1) == 'B' & trade_no.Length>=1)
                {
                    if(trade_no.Substring(0, 1) != '来')
                       message += '备案号第一位为B的，贸易方式必须是以来开头！';
                }
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "备案号第一位为B的，贸易方式必须是以来开头！");

            mains = new t_mains();
            mains.records_no = "B";//备案号
            mains.trade_no = "来";// 贸易方式

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");

        }

        /// <summary>
        /// 逻辑校验55 ID 93   备案号第一位为C的，贸易方式必须是以进开头！
        /// </summary>
        [TestMethod]
        public void TestLogic55()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.records_no = "";//备案号
            mains.trade_no = "";// 贸易方式

            string role = functionstr + @"
            message = '';
            records_no =   RemoveNull(tmains.records_no); //备案号
            trade_no = RemoveNull(tmainextsinfo['trade_name'] );;//贸易方式
          
            if(records_no.Length>=1){
                if(  records_no.Substring(0, 1) == 'C' & trade_no.Length<1)
                {
                  message += '备案号第一位为C的，贸易方式必须是以进开头！';
                }
                if( records_no.Substring(0, 1) == 'C' & trade_no.Length>=1)
                {
                    if(trade_no.Substring(0, 1) != '进')
                       message += '备案号第一位为C的，贸易方式必须是以进开头！';
                }
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "备案号第一位为C的，贸易方式必须是以进开头！");

            mains = new t_mains();
            mains.records_no = "C";//备案号
            mains.trade_no = "进";// 贸易方式

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");

        }

        /// <summary>
        /// 逻辑校验56 ID 94    境内货源地与经营单位代码不符！
        /// </summary>
        [TestMethod]
        public void TestLogic56()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 1;//进出口
            mains.records_no = "wew";// 备案号
            mains.shipper_no = "1334567788";//经营单位编码
            mains.end_country_no = "12345";//境内货源地
            string role = functionstr + @"
            message = '';
            declare_id = RemoveNull(tmains.declare_id);//进出口
            records_no =   RemoveNull(tmains.records_no); //备案号
            shipper_no = RemoveNull(tmains.shipper_no);//经营单位编码
            end_country_no =   RemoveNull(tmains.end_country_no); //境内货源地

            if(declare_id == '1' & records_no.Length > 0 )
            {
               if(shipper_no.Length >=5 ){
                     if(shipper_no.Substring(0,5) !=  end_country_no)
                         message += '境内货源地与经营单位代码不符！';
                }
                else{
                      message += '境内货源地与经营单位代码不符！';
                }
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "境内货源地与经营单位代码不符！");

            mains = new t_mains();
            mains.declare_id = 1;//进出口
            mains.records_no = "ewr";// 备案号
            mains.shipper_no = "1234567788";//经营单位编码
            mains.end_country_no = "12345";//境内货源地
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验57 ID 95    商品编码错误！
        /// </summary>
        [TestMethod]
        public void TestLogic57()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.goods_no = "";
            goodslist.Add(goods);

            t_goods_details goods2 = new t_goods_details();
            goods2.goods_no = "035";
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '';
            foreach (goods in goodslist) 
            {
               goods_no = RemoveNull(goods.goods_no);
                if( goods_no.Trim().Length == 0){
                    message += '商品编码为空！';
                    break;
                }
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "商品编码为空！");


            goodslist = new List<t_goods_details>();
            goods = new t_goods_details();
            goods.goods_no = "1";
            goodslist.Add(goods);

            goods2 = new t_goods_details();
            goods2.goods_no = "2";
            goodslist.Add(goods2);

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验58  ID 96   运费为率时最多只能2位小数
        /// </summary>
        [TestMethod]
        public void TestLogic58()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.freightmode_no = "1";//运费1
            mains.freight = (decimal?)2.987;//运费2

            string role = functionstr + @"
            message = '';
            freightmode_no =   RemoveNull(tmains.freightmode_no); //运费1
            freight = (string)(double) DigitalRemoveNull(tmains.freight); //运费2
            reg = new Regex(@'^(\-)?\d+(\.\d{1,2})?$');
            if(freightmode_no == '1' & !reg.IsMatch(freight))
            {
                 message +='运费为率时最多只能2位小数';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "运费为率时最多只能2位小数");
            mains = new t_mains();
            mains.freightmode_no = "1";//运费1
            mains.freight = (decimal?)2.97;//运费2
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验59  ID 97   运费为单价或者总价时最多只能4位小数
        /// </summary>
        [TestMethod]
        public void TestLogic59()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.freightmode_no = "2";//运费1
            mains.freight = (decimal?)2.55987;//运费2

            string role = functionstr + @"
            message = '';
            freightmode_no =   RemoveNull(tmains.freightmode_no); //运费1
            freight =   (string)(double) DigitalRemoveNull(tmains.freight); //运费2
            reg = new Regex(@'^(\-)?\d+(\.\d{1,4})?$');
            if((freightmode_no == '2' | freightmode_no == '3') & !reg.IsMatch(freight))
            {
                 message +='运费为单价或者总价时最多只能4位小数';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "运费为单价或者总价时最多只能4位小数");
            mains = new t_mains();
            mains.freightmode_no = "3";//运费1
            mains.freight = (decimal?)2.9987;//运费2
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验60 ID 98    保费为率时最多只能2位小数
        /// </summary>
        [TestMethod]
        public void TestLogic60()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.subscribemode_no = "1";//保费1
            mains.subscribe = (decimal?)1.231;//保费2

            string role = functionstr + @"
            message = '';
            subscribemode_no =   RemoveNull(tmains.subscribemode_no); //保费1
            subscribe =   (string)(double) DigitalRemoveNull(tmains.subscribe); //保费2
            reg = new Regex(@'^(\-)?\d+(\.\d{1,2})?$');
            if(subscribemode_no == '1'   & !reg.IsMatch(subscribe))
            {
                 message +='保费为率时最多只能2位小数';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "保费为率时最多只能2位小数");
            mains = new t_mains();
            mains.freightmode_no = "1";//保费1
            mains.freight = (decimal?)2.9;//保费1
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验61 ID 99   保费为单价或者总价时最多只能4位小数
        /// </summary>
        [TestMethod]
        public void TestLogic61()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.subscribemode_no = "2";//保费1
            mains.subscribe = (decimal?)1.245431;//保费2

            string role = functionstr + @"
            message = '';
            subscribemode_no =   RemoveNull(tmains.subscribemode_no); //保费1
            subscribe =   (string)(double) DigitalRemoveNull(tmains.subscribe); //保费2
            reg = new Regex(@'^(\-)?\d+(\.\d{1,4})?$');
            if((subscribemode_no == '2' | subscribemode_no == '3') & !reg.IsMatch(subscribe))
            {
                 message +='保费为单价或者总价时最多只能4位小数';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "保费为单价或者总价时最多只能4位小数");
            mains = new t_mains();
            mains.subscribemode_no = "2";//保费1
            mains.subscribe = (decimal?)1.2431;//保费2
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }


        /// <summary>
        /// 逻辑校验62   ID 100  杂费为率时最多只能2位小数
        /// </summary>
        [TestMethod]
        public void TestLogic62()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.incidentalmode_no = "1";//杂费1
            mains.incidental = (decimal?)2.345;//杂费2

            string role = functionstr + @"
            message = '';
            incidentalmode_no =   RemoveNull(tmains.incidentalmode_no); //杂费1
            incidental =    (string)(double) DigitalRemoveNull(tmains.incidental); //杂费2
            reg = new Regex(@'^(\-)?\d+(\.\d{1,2})?$');
            if(incidentalmode_no == '1'   & !reg.IsMatch(incidental))
            {
                 message +='杂费为率时最多只能2位小数';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "杂费为率时最多只能2位小数");
            mains = new t_mains();
            mains.incidentalmode_no = "1";//杂费1
            mains.incidental = (decimal?)2.9;//杂费2
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验63 ID 101   杂费为单价或者总价时最多只能4位小数
        /// </summary>
        [TestMethod]
        public void TestLogic63()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.incidentalmode_no = "2";//杂费1
            mains.incidental = (decimal?)2.35645;//杂费2

            string role = functionstr + @"
            message = '';
            incidentalmode_no =   RemoveNull(tmains.incidentalmode_no); //杂费1
            incidental =   (string)(double) DigitalRemoveNull(tmains.incidental); //杂费2
            reg = new Regex(@'^(\-)?\d+(\.\d{1,4})?$');
            if((incidentalmode_no == '2' | incidentalmode_no == '3') & !reg.IsMatch(incidental))
            {
                 message +='杂费为单价或者总价时最多只能4位小数';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "杂费为单价或者总价时最多只能4位小数");
            mains = new t_mains();
            mains.incidentalmode_no = "3";//杂费1
            mains.incidental = (decimal?)2.345;//杂费2
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验64  103  商品编码对应监管条件与报关单不符 
        /// </summary>
        [TestMethod]
        public void TestLogic64()
        {
            //0908210000   已磨的豆蔻 880826
            //0908320000  已磨的豆蔻  880901
            try
            {
                t_mains t_main = fuliuEntities.t_mains.Where(i => i.id == 886528).Single();

                string role = functionstr + @"
                        if(controlMsg == '1')
                           {
                               message = '商品编码对应监管条件与报关单不符';
                           }
                        ";
                var msg = FL.RuleEngine.Core.RoleRuntimeHost.CheckGoodsControl(t_main.id, (int)t_main.declare_id);
                string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(t_main, role, null, null, null, null, null, null);
                //Assert.AreEqual(message, "商品编码对应监管条件与报关单不符");


            }
            catch (Exception e)
            {
            }

        }

        /// <summary>
        /// 执行SQL 返回datatable
        /// </summary>
        /// <param name="queryText"></param>
        /// <param name="parametes"></param>
        /// <returns></returns>
        public DataTable QueryToTable(string queryText, SqlParameter[] parametes)
        {
            using (DbDataAdapter adapter = new SqlDataAdapter())
            {
                adapter.SelectCommand = fuliuEntities.Database.Connection.CreateCommand();
                adapter.SelectCommand.CommandText = queryText;
                if (parametes != null)
                    adapter.SelectCommand.Parameters.AddRange(parametes);
                DataTable table = new DataTable();
                adapter.Fill(table);
                return table;
            }
        }

        /// <summary>
        /// 逻辑校验65 ID 106   输入了无监管条件的证件代码或内容
        /// </summary>
        [TestMethod]
        public void TestLogic65()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.incidentalmode_no = "2";//杂费1
            mains.incidental = (decimal?)2.35645;//杂费2
            List<t_goods_details> goodslist = new List<t_goods_details>();
            var goods = new t_goods_details();
            goods.country_no = "A"; //监管条件
            var goods2 = new t_goods_details();
            goods2.country_no = "B"; //监管条件
            goodslist.Add(goods);
            goodslist.Add(goods2);

            List<t_accompany_details> accompanylist = new List<t_accompany_details>();
            var accompany = new t_accompany_details();
            accompany.control_no = "A";
            accompanylist.Add(accompany);

            string role = functionstr + @"
            message = '';
            count =(double)country_nocount2;
            if(count >0)
            {
                 message +='输入了无监管条件的证件代码或内容';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist, null, accompanylist);
            Assert.AreEqual(message, "输入了无监管条件的证件代码或内容");

        }



        /// <summary>
        /// 逻辑校验66  ID 108  出口结汇方式不能为空!
        /// </summary>
        [TestMethod]
        public void TestLogic66()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 1; //进出口
            mains.remitmode_no = "";//结汇方式

            string role = functionstr + @"
            message = '';
            declare_id =  RemoveNull(tmains.declare_id); //进出口
            remitmode_no = RemoveNull(tmains.remitmode_no);//结汇方式
           
            if( declare_id == '1' & remitmode_no.Trim().Length == 0)
            {
               message +='出口结汇方式不能为空!';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "出口结汇方式不能为空!");

            mains = new t_mains();
            mains.declare_id = 1; //进出口
            mains.remitmode_no = "s";//结汇方式
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验67 ID 110  通关单号的所属口岸与报关单不一致！
        /// </summary>
        [TestMethod]
        public void TestLogic67()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.tgdstatus = "1|2"; //通关状态
            mains.port_no = "";//口岸

            string role = functionstr + @"
            message = '';
              if(clearanceState!='4'){
		     return message;
		      }
            tgdstatus =  RemoveNull(tmains.tgdstatus); //通关状态
            port_no = RemoveNull(tmains.port_no);//口岸

            ltemp='';
            splitchar = new Char[1];
            splitchar[0] = '|';
             
            subtgdstatus  =    tgdstatus.Split(splitchar);

           if(subtgdstatus.Length>=2  )
             ltemp =    subtgdstatus[1].ToString();
  
            if( ltemp.Length >0  & ltemp!='5300' & ltemp != port_no)
            {
               message +='通关单号的所属口岸与报关单不一致！';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "通关单号的所属口岸与报关单不一致！");

            mains = new t_mains();
            mains.tgdstatus = "1|2"; //通关状态
            mains.port_no = "2";//口岸
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");

            mains = new t_mains();
            mains.tgdstatus = ""; //通关状态
            mains.port_no = "2";//口岸
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }
        /// <summary>
        /// 校验通关单号128
        /// </summary>
        [TestMethod]
        public void TestLogic128()
        {

            t_mains t_main = fuliuEntities.t_mains.Where(i => i.id == 909151).Single();
            string msg = FL.RuleEngine.Core.RoleRuntimeHost.CheckClearanceState(t_main.id, (int)t_main.declare_id, t_main.tgdstatus);
            string role = @" message = '' ; 
                           if(clearanceState == '2')
                           {
                               message = '根据商品监管条件需要输入通关单号';
                           } 
                            if(clearanceState == '3')
                           {
                               message = '输入了通关单号还没有获取通关单状态';
                           } 
                          return message;";
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic["clearanceState"] = "0";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(t_main, role, dic, null, null, null, null, null);

        }

        /// <summary>
        /// 逻辑校验68  ID 111 通关单状态与经营单位编码不符!
        /// </summary>
        [TestMethod]
        public void TestLogic68()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.tgdstatus = "1|2|3"; //通关状态
            mains.shipper_no = "";//经营单位编码


            string role = functionstr + @"
            message = '';
  if(clearanceState!='4'){
		     return message;
		      }
            tgdstatus =  RemoveNull(tmains.tgdstatus); //通关状态
            shipper_no = RemoveNull(tmains.shipper_no);//口岸

            ltemp='';
            splitchar = new Char[1];
            splitchar[0] = '|';
             
            subtgdstatus  =    tgdstatus.Split(splitchar);

           if(subtgdstatus.Length>=3  )
             ltemp =    subtgdstatus[2].ToString();
  
            if( ltemp.Length >0    & ltemp != shipper_no)
            {
               message +='通关单状态与经营单位编码不符!';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "通关单状态与经营单位编码不符!");

            mains = new t_mains();
            mains.tgdstatus = "1|2|3"; //通关状态
            mains.shipper_no = "3";//经营单位编码
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");

            mains = new t_mains();
            mains.tgdstatus = ""; //通关状态
            mains.port_no = "2";//口岸
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验69  ID 112 通关单过期了!
        /// </summary>
        [TestMethod]
        public void TestLogic69()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.tgdstatus = "1|2|3|4|5|2015-05-21"; //通关状态
            string role = functionstr + @"
            message = '';
  if(clearanceState!='4'){
		     return message;
		      }
            tgdstatus =  RemoveNull(tmains.tgdstatus); //通关状态
            ltemp='';
            splitchar = new Char[1];
            splitchar[0] = '|';
            subtgdstatus  =    tgdstatus.Split(splitchar);

           if(subtgdstatus.Length>=6  )
             ltemp =    subtgdstatus[5].ToString();
           
            now = DateTime.Now.ToString('yyyy-MM-dd');
            if( ltemp.Length >0    & ltemp < now)
            {
               message +='通关单过期了!';
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "通关单过期了!");

            mains = new t_mains();
            mains.tgdstatus = "1|2|3|4|5|2015-05-22"; //通关状态
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
            mains = new t_mains();
            mains.tgdstatus = ""; //通关状态
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验70 ID 114   通关单国家跟与运抵国不一致
        /// </summary>
        [TestMethod]
        public void TestLogic70()
        {
            FL.Entity.DB.t_mains mains = fuliuEntities.t_mains.Where(t => t.id == 881097).FirstOrDefault();
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic["start_country_name"] = "日本";
            dic["clearanceState"] = "4";

            //FL.Entity.DB.t_mains mains = fuliuEntities.t_mains.Where(t => t.id == 874867).Single();
            List<t_goods_details> goodslist = fuliuEntities.t_goods_details.Where(t => t.t_main_id == 881097).ToList();
            string role = functionstr + @"
            message = '';
  if(clearanceState!='4'){
		     return message;
		      }
            tgdstatus =  tmains.tgdstatus; //通关状态
            declare_id =  tmains.declare_id; //进出口
            ltemp='';
            splitchar = new Char[1];
            splitchar[0] = '|';
            subtgdstatus  =    tgdstatus.Split(splitchar);
           if(subtgdstatus.Length>=5 )
            ltemp =subtgdstatus[4].ToString();
            if(ltemp != start_country_name)
            {
                message +='通关单国家跟运抵国不一致';
             }
            if( ltemp.Length >0    & declare_id == '1')
            {
                foreach (goods in goodslist) 
                {
                    if(ltemp != goods.country_name){
                        message +='通关单国家跟与商品目的国不一致';
                        break;
                    }
                }
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, dic, goodslist);
            Assert.AreEqual(message, "通关单国家跟与运抵国不一致");

            //goodslist = new List<t_goods_details>();
            //goods = new t_goods_details();
            //goods.country_no = "555";
            //goodslist.Add(goods);// 目的国
            //message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, goodslist);
            //Assert.AreEqual(message, "");
        }


        /// <summary>
        /// 逻辑校验71  ID 115  必须填写成交方式
        /// </summary>
        [TestMethod]
        public void TestLogic71()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 1; //进出口
            mains.bargainmode_no = null; //成交方式

            string role = functionstr + @"
            message = '';
            declare_id =  RemoveNull(tmains.declare_id); //进出口
            bargainmode_no =  RemoveNull(tmains.bargainmode_no); //成交方式
            if(declare_id == '1'  & bargainmode_no.Trim().Length == 0 )
              message +=    '必须填写成交方式';
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "必须填写成交方式");

            mains = new t_mains();
            mains.declare_id = 1; //进出口
            mains.bargainmode_no = ""; //成交方式
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "必须填写成交方式");

            mains = new t_mains();
            mains.declare_id = 1; //进出口
            mains.bargainmode_no = "2"; //成交方式
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验72  ID 116 码头必须跟口岸对应
        /// </summary>
        [TestMethod]
        public void TestLogic72()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.wharf_id = 10239; //码头
            mains.port_no = "5305"; //口岸
            string role = functionstr + @"
            message = '';
            wharf_id =  RemoveNull(tmains.wharf_id); //码头
            port_no =  RemoveNull(tmains.port_no); //口岸
            code1 = '10239,10240,10241,10242';
            code2 = '10245';
            if((code1.Contains(wharf_id) & port_no !='5304' )
               | (code2.Contains(wharf_id) & port_no !='5349')
               ){
               message += '码头必须跟口岸对应';
              }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "码头必须跟口岸对应");

            mains = new t_mains();
            mains.wharf_id = 10245; //码头
            mains.port_no = "5305"; //口岸
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "码头必须跟口岸对应");

            mains = new t_mains();
            mains.wharf_id = 10239; //进出口
            mains.port_no = "5304"; //成交方式
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验73 ID 117 包装方式不能为空
        /// </summary>
        [TestMethod]
        public void TestLogic73()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.pack_no = "";//包装方式

            string role = functionstr + @"
            message = '';
            pack_no =  RemoveNull(tmains.pack_no); //码头
            
            if( pack_no.Trim().Length == 0){
               message += '包装方式不能为空';
              }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "包装方式不能为空");

            mains = new t_mains();
            mains.pack_no = "asdf";//包装方式
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");

        }

        /// <summary>
        /// 逻辑校验74  ID 118 流水号长度不符或者流水号第2位与大铲不一致！
        /// </summary>
        [TestMethod]
        public void TestLogic74()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 1;//进出口
            mains.port_no = "5348";// 口岸
            mains.cabin_no = "163456789876";// 提运单号

            string role = functionstr + @"
            message = '';
            declare_id =  RemoveNull(tmains.declare_id); //进出口
            port_no =  RemoveNull(tmains.port_no); //口岸
            cabin_no =  RemoveNull(tmains.cabin_no); //提运单号
            if( declare_id == '1' & port_no== '5348' ){
               if(cabin_no.Length !=12 | cabin_no.Substring(1,1) != '6' ){
                      message += '流水号长度不符或者流水号第2位与大铲不一致！';
                 }
              }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "流水号长度不符或者流水号第2位与大铲不一致！");

            mains = new t_mains();
            mains.declare_id = 1;//进出口
            mains.port_no = "5348";// 口岸
            mains.cabin_no = "173456789876";// 提运单号
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");

        }

        /// <summary>
        /// 逻辑校验75  ID 119 以B/C开始的手册号不需要录入版本号
        /// </summary>
        [TestMethod]
        public void TestLogic75()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.records_no = "B";// 备案号
            List<t_goods_details> goodslist = new List<t_goods_details>();
            t_goods_details goods = new t_goods_details();
            goods.ver_no = "035";
            goodslist.Add(goods);
            t_goods_details goods2 = new t_goods_details();
            goods2.ver_no = "";
            goodslist.Add(goods2);

            string role = functionstr + @"
            message = '' ;
            records_no =  RemoveNull(tmains.records_no); //备案号
            if(records_no.Trim().Length >1){
                no = records_no.Substring(0,1);
                    if( no == 'B' | no == 'C'  ){
                        foreach (goods in goodslist) 
                        {
                            ver_no = RemoveNull(goods.ver_no);
                            if(ver_no.Length >0 ){
                            message += '以B/C开始的手册号不需要录入版本号';
                            break;
                        }
                    }
                }
            }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "以B/C开始的手册号不需要录入版本号");

            mains = new t_mains();
            mains.records_no = "B";// 备案号
            goodslist = new List<t_goods_details>();
            goods = new t_goods_details();
            goods.ver_no = null;
            goodslist.Add(goods);
            goods2 = new t_goods_details();
            goods2.ver_no = "";
            goodslist.Add(goods2);

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null, goodslist);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验76 ID 120 华星光电备案号Z开头的征免性质只能是新型显示器(423)或者鼓励项目(789)   
        /// </summary>
        [TestMethod]
        public void TestLogic76()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.records_no = "ZASD";// 备案号
            mains.shipper_no = "4403137916";// 经营单位编码
            mains.imposemode_no = "453";// 征免性质

            string role = functionstr + @"
            message = '' ;
            records_no =  RemoveNull(tmains.records_no); //备案号
            shipper_no =  RemoveNull(tmains.shipper_no); //经营单位编码
            imposemode_no =  RemoveNull(tmains.imposemode_no); //征免性质
             if(records_no.Trim().Length >1){
                no = records_no.Substring(0,1);
                if( shipper_no == '4403137916' &  no == 'Z'  ){
                    if( !(imposemode_no == '423' | imposemode_no == '789')){
                            message += '华星光电备案号Z开头的征免性质只能是新型显示器(423)或者鼓励项目(789)';
                    }
                }
             }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "华星光电备案号Z开头的征免性质只能是新型显示器(423)或者鼓励项目(789)");

            mains = new t_mains();
            mains.records_no = "ZASD";// 备案号
            mains.shipper_no = "4403137916";// 经营单位编码
            mains.imposemode_no = "423";// 征免性质

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验77 ID 121 航次跟运输工具不能同时填写
        /// </summary>
        [TestMethod]
        public void TestLogic77()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.port_no = "5301";// 口岸
            mains.voyage = "ZASD";// 航次
            mains.transname = "ZASD";//运输工具

            string role = functionstr + @"
            message = '' ;
            port_no =  RemoveNull(tmains.port_no); //口岸
            voyage =  RemoveNull(tmains.voyage); //航次
            transname =  RemoveNull(tmains.transname); //运输工具
            ports =  '5301,5345,5320';
            if(ports.Contains(port_no)  & voyage.Trim().Length >0 & transname.Trim().Length>0 ){
                         message += '航次跟运输工具不能同时填写';
              }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "航次跟运输工具不能同时填写");

            mains = new t_mains();
            mains.port_no = "5301";// 口岸
            mains.vessel = "ZASD";// 航次
            mains.transname = "";//运输工具

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验78 ID 122 不是进料成品退换与来料成品退换对应的征免性质不能为空
        /// </summary>
        [TestMethod]
        public void TestLogic78()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.trade_no = "5301";// 贸易方式
            mains.imposemode_no = "";// 征免性质
            string role = functionstr + @"
            message = '' ;
            trade_no =  RemoveNull(tmains.trade_no); //贸易方式
            imposemode_no =  RemoveNull(tmains.imposemode_no); //征免性质
            if( trade_no != '4600' & trade_no != '4400' & ( imposemode_no.Trim().Length == 0 | imposemode_no == '000' )  ){
                         message += '不是进料成品退换与来料成品退换对应的征免性质不能为空';
              }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "不是进料成品退换与来料成品退换对应的征免性质不能为空");

            mains = new t_mains();
            mains.trade_no = "5301";// 贸易方式
            mains.imposemode_no = "asdf";// 征免性质

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验79 ID 123   皇岗经营单位是<厦门国贸泰达保税物流有限公司>时，进出口岸必须是深圳湾关
        /// </summary>
        [TestMethod]
        public void TestLogic79()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.shipper_no = "3502430273";// 经营单位编码
            mains.org_id = "3a8580d4-875e-436c-9f22-938c9c6ac392";// 分公司
            mains.port_no = "sdf";// 口岸

            string role = functionstr + @"
            message = '' ;
            shipper_no =  RemoveNull(tmains.shipper_no); //经营单位编码
            org_id =  RemoveNull(tmains.org_id); //分公司
            port_no =  RemoveNull(tmains.port_no); //口岸

            if( shipper_no == '3502430273' & org_id == '3a8580d4-875e-436c-9f22-938c9c6ac392' & port_no.Length >0 & port_no !=  '5345'){
                         message += '皇岗经营单位是<厦门国贸泰达保税物流有限公司>时，进出口岸必须是深圳湾关';
              }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "皇岗经营单位是<厦门国贸泰达保税物流有限公司>时，进出口岸必须是深圳湾关");

            mains = new t_mains();
            mains.shipper_no = "3502430273";// 经营单位编码
            mains.org_id = "3a8580d4-875e-436c-9f22-938c9c6ac392";// 分公司
            mains.port_no = "5345";// 口岸

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验80 ID 124   出口一般贸易的经营单位与发货单位的名称和代码需要一致
        /// </summary>
        [TestMethod]
        public void TestLogic80()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.declare_id = 1;// 进出口
            mains.shipper_name = "3a8580d4-875e-436c-9f22-938c9c6ac392";// 经营单位
            mains.shipper_no = "sdf";// 经营单位编码
            mains.consignee_name = "3a8580d4-875e-436c-9f22-938c9c392";// 发货单位
            mains.consignee_no = "sd";// 发货单位编码
            mains.trade_no = "0110";//贸易方式

            string role = functionstr + @"
            message = '' ;
            declare_id =  RemoveNull(tmains.declare_id); //进出口
            shipper_no =  RemoveNull(tmains.shipper_no); //经营单位编码
            shipper_name =  RemoveNull(tmains.shipper_name); //经营单位
            consignee_name =  RemoveNull(tmains.consignee_name); //发货单位
            consignee_no =  RemoveNull(tmains.consignee_no); //发货单位编码
            trade_no =  RemoveNull(tmains.trade_no); //贸易方式

            if( (shipper_name !=  consignee_name | shipper_no != consignee_no) &
              declare_id == '1' & trade_no == '0110'
              ){
                         message += '出口一般贸易的经营单位与发货单位的名称和代码需要一致';
              }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "出口一般贸易的经营单位与发货单位的名称和代码需要一致");

            mains = new t_mains();
            mains.declare_id = 1;// 进出口
            mains.shipper_name = "AAA";// 经营单位
            mains.shipper_no = "aaa";// 经营单位编码
            mains.consignee_name = "AAA";// 发货单位
            mains.consignee_no = "aaa";// 发货单位编码
            mains.trade_no = "0110";//贸易方式

            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "SDF");
        }


        /// <summary>
        /// 逻辑校验81 ID 126  经营单位为“航天科工深圳(集团)有限公司”，合同号必须以“KG”开头
        /// </summary>
        [TestMethod]
        public void TestLogic81()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.shipper_name = "3a8580d4-875e-436c-9f22-938c9c6ac392";// 经营单位
            mains.shipper_no = "4403112086";// 经营单位编码
            mains.contract_no = "4403112086";//合同号

            string role = functionstr + @"
            message = '' ;
            shipper_no =  RemoveNull(tmains.shipper_no); //经营单位编码
            shipper_name =  RemoveNull(tmains.shipper_name); //经营单位
            contract_no =  RemoveNull(tmains.contract_no); //合同号

           if(contract_no.Length >=2)
              contract_no.Substring(0, 2);

            if( (shipper_no ==  '4403112086' & contract_no != 'KG') ){
                 message += '经营单位为[航天科工深圳(集团)有限公司]，合同号必须以“KG”开头';
              }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "经营单位为[航天科工深圳(集团)有限公司]，合同号必须以“KG”开头");
            mains = new t_mains();
            mains.shipper_name = "3a8580d4-875e-436c-9f22-938c9c6ac392";// 经营单位
            mains.shipper_no = "4403112086";
            mains.contract_no = "KG";//合同号
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }

        /// <summary>
        /// 逻辑校验81 ID 127  经营单位为“深圳航天广宇工业有限公司”，合同号必须以“GY”开头
        /// </summary>
        [TestMethod]
        public void TestLogic82()
        {
            FL.Entity.DB.t_mains mains = new t_mains();
            mains.shipper_name = "3a8580d4-875e-436c-9f22-938c9c6ac392";// 经营单位
            mains.shipper_no = "4403111365";// 经营单位编码
            mains.contract_no = "4403111365";//合同号

            string role = functionstr + @"
            message = '' ;
            shipper_no =  RemoveNull(tmains.shipper_no); //经营单位编码
            shipper_name =  RemoveNull(tmains.shipper_name); //经营单位
            contract_no =  RemoveNull(tmains.contract_no); //合同号

           if(contract_no.Length >=2)
              contract_no.Substring(0, 2);

            if( (shipper_no ==  '4403111365' & contract_no != 'GY') ){
                 message += '经营单位为“深圳航天广宇工业有限公司”，合同号必须以“GY”开头';
              }
             return message;
            ";
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "经营单位为“深圳航天广宇工业有限公司”，合同号必须以“GY”开头");
            mains = new t_mains();
            mains.shipper_name = "3a8580d4-875e-436c-9f22-938c9c6ac392";// 经营单位
            mains.shipper_no = "4403112086";
            mains.contract_no = "GY";//合同号
            message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
            Assert.AreEqual(message, "");
        }


        [TestMethod]
        public void TestLogicAll()
        {
            var id = 18;
            var tmains = fuliuEntities.t_mains.Where(t => t.id == id).SingleOrDefault();
            var logiclist = fuliuEntities.logics.ToList();
            var goodslist = fuliuEntities.t_goods_details.Where(t => t.t_main_id == id).ToList();
            string message = "";

            logiclist.ForEach(s =>
            {
                try
                {
                    string role = functionstr + " message = ''; ";
                    role += s.csharpexp;
                    role += " return message; ";
                    message += FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(tmains, role, null, goodslist);
                }
                catch (Exception e)
                {
                    message += s.id + "异常";
                }
            });
            string result = message;


        }
        //校验备案号E开头的商品信息必须填写版本号
        [TestMethod]
        public void Test129()
        {
            t_mains t_main = fuliuEntities.t_mains.Where(i => i.id == 903054).Single();
            List<t_goods_details> list = fuliuEntities.t_goods_details.Where(t => t.t_main_id == 903054).ToList();
            string role = functionstr + @" 
            message = '' ;
            declare_id =   RemoveNull(tmains.declare_id); //进出口
            records_no = RemoveNull(tmains.records_no); //备案号
            if(records_no != ''&&records_no!=null )
            {
          
               if (records_no.Substring(0,1).ToUpper()=='E')
                {
                    
                    foreach (goods in goodslist)
                    {
                     if (goods.ver_no == ''||goods.ver_no==null)
                       {
                           
                           message += '备案号E开头的商品信息必须填写版本号！';
                           break;
                       }
                       
                    }
                }
            }
      return message;
";


            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(t_main, role, null, list, null, null, null, null);
        }

        //校验同名异归类错误
        [TestMethod]
        public void Test311()
        {
            //0908210000   已磨的豆蔻 880826
            //0908320000  已磨的豆蔻  880901
            try
            {
                t_mains t_main = fuliuEntities.t_mains.Where(i => i.id == 902310).Single();
                string msg = FL.RuleEngine.Core.RoleRuntimeHost.CheckGoodsNameType(902310);
                string role = @" message = '' ; 
                           if(checkGoodsNameType == '1')
                           {
                               message = '同名异归类错误';
                           } 
                          return message;";
                string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(t_main, role, null, null, null, null, null, null);

            }
            catch (Exception e)
            {


            }
        }

        [TestMethod]
        public void Test137()
        {
            //0908210000   已磨的豆蔻 880826
            //0908320000  已磨的豆蔻  880901
            try
            {
                LogicCheck check = new LogicCheck(927079);
                var message = check.LogicCheck137();


            }
            catch (Exception e)
            {


            }
        }


        [TestMethod]
        public void Test142()
        {
            //0908210000   已磨的豆蔻 880826
            //0908320000  已磨的豆蔻  880901
            try
            {
                LogicCheck check = new LogicCheck(967592);
                var message = check.LogicCheck142();


            }
            catch (Exception e)
            {


            }
        }


        [TestMethod]
        public void Test143()
        {
            //0908210000   已磨的豆蔻 880826
            //0908320000  已磨的豆蔻  880901
            try
            {
                LogicCheck check = new LogicCheck(967592);
                var message = check.LogicCheck168();


            }
            catch (Exception e)
            {


            }
        }





        [TestMethod]
        public void TestLogicOnceAll()
        {
            var id = 18;
            var tmains = fuliuEntities.t_mains.Where(t => t.id == id).SingleOrDefault();
            var goodslist = fuliuEntities.t_goods_details.Where(t => t.t_main_id == id).ToList();

            var logiclist = fuliuEntities.logics.ToList();
            string message = "";
            string role = functionstr + " message = '';  ";
            logiclist.ForEach(s =>
            {
                role += s.csharpexp;

            });

            role += " return message; ";

            try
            {
                message += FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(tmains, role, null, goodslist);

            }
            catch (Exception e)
            {
            }

            string result = message;


        }

        #endregion
















        /// <summary>
        /// 测试规则引擎  获取数据
        /// </summary>
        [TestMethod]
        public void TestRuleEngineDb()
        {
            DataTable table = new DataTable();
            string role = @" 
            db= new dal();   
            dataset = db.Query('select * from [dbo].t_goods_details a where a.t_main_id =2');
            table = dataset.Tables[0];
            result ='';
            for (  i = 0; i < table.Rows.Count; i++)
            {
                row = table.Rows[i];
                for (j = 0; j < table.Columns.Count; j++)
                {
                    result += row[table.Columns[j].ColumnName].ToString() + ',';
                }
            }
            return result;
             ";
            FL.Entity.DB.t_mains mains = new t_mains();
            string message = FL.RuleEngine.Core.RoleRuntimeHost.CheckTMainsData(mains, role, null);
        }



        //[TestMethod]
        //public void TestCode()
        //{


        //}
        private Hashtable GetHashColumns(string tableName)
        {
            Hashtable hashtable1 = new Hashtable();

            try
            {
                //FL.Common.Configuration.GetConfig()
                SqlConnection connection1 = new SqlConnection(FL.Common.AppSettingsHelper.GetString("dataconn"));
                string text1 = "select top 1 * from [" + tableName + "]";
                SqlDataAdapter adapter1 = new SqlDataAdapter(text1, connection1);
                DataSet set1 = new DataSet();
                adapter1.Fill(set1);
                connection1.Close();
                foreach (DataColumn column1 in set1.Tables[0].Columns)
                {
                    hashtable1.Add(column1.ColumnName, column1.DataType);
                }
            }
            catch { }
            return hashtable1;
        }



        private void CreateCSharpCode(string tableName)
        {
            //Hashtable hashtable1 = this.GetHashColumns(tableName);
            //if (!this.txtFolder.Text.EndsWith(@"\"))
            //{
            //    this.txtFolder.Text = this.txtFolder.Text + @"\";
            //}
            //string guid = GetGuid(tableName);

            //string text1 = string.Concat(new string[] { this.txtFolder.Text, this.txtProject.Text, @"\", tableName, ".cs" });
            //StringBuilder builder1 = new StringBuilder();
            //builder1.Append("using System;\r\n");
            //builder1.Append("using System.ComponentModel;\r\n");
            //builder1.Append("using Csla;\r\n");
            //builder1.Append("using lite;\r\n");
            //builder1.Append("using Csla.Validation;\r\n");
            //builder1.Append("using Csla.Data;\r\n");
            //builder1.Append("using System.Data.SqlClient;\r\n");
            //builder1.Append("using OpenExpressApp.ORM;\r\n");

            //builder1.Append("namespace " + this.txtNamespace.Text + "\r\n");
            //builder1.Append("{\r\n");
            //builder1.Append("\t[Serializable]\r\n");
            //builder1.Append("\t[Table(Name = \"" + tableName + "\")]\r\n");
            //builder1.Append("\t[ZX.DBModule.Table(\"" + tableName + "\",\"" + guid + "\")]\r\n");
            //builder1.Append("\tpublic class  " + tableName + "\r\n");
            //builder1.Append("\t{\n");
            //builder1.Append("\t\tpublic " + tableName + "()\n");
            //builder1.Append("\t\t{\n\n");
            //builder1.Append("\t\t}\n\n");


            //IDictionaryEnumerator enumerator1 = hashtable1.GetEnumerator();
            //while (enumerator1.MoveNext())
            //{
            //    builder1.Append(this.AddProperty(enumerator1.Key.ToString(), enumerator1.Value.ToString()));
            //}
            //builder1.Append("\t}\n");
            //builder1.Append("}\n");
            //StreamWriter writer1 = new StreamWriter(text1);
            //writer1.Write(builder1);
            //writer1.Close();
        }
    }
}
